表products
表xl
现在我想读取xl里面的10条记录,但是xl_id要等于products表里的p_xlid,并且p_xlid只取products里面的以p_browsecount DESC排序的前10条
我用的这个取出来有重复记录
SELECT TOP 10 xl_info.xl_id,xl_info.xl_name FROM products,xl_info WHERE (xl_info.xl_id=products.p_xlid) ORDER BY products.p_browsecount DESC
表xl
现在我想读取xl里面的10条记录,但是xl_id要等于products表里的p_xlid,并且p_xlid只取products里面的以p_browsecount DESC排序的前10条
我用的这个取出来有重复记录
SELECT TOP 10 xl_info.xl_id,xl_info.xl_name FROM products,xl_info WHERE (xl_info.xl_id=products.p_xlid) ORDER BY products.p_browsecount DESC
解决方案 »
- asp.net生成静态页面出现错误怎么修改,求各位哥哥救救
- 页面刷新时,怎样阻止“重试”和“取消”提示框弹出
- 怎样用代码实现gridview的编辑,删除.
- 如何在运行时将添加到DataGrid模板列中的按钮Disable啊?
- 为什么ASP.NET中下载文件时会出现2个确认对话框???
- 这些宝贵资料适合入门的朋友学习
- 请问,怎么将TreeView中的ToolTip的默认值(Use+/-…………)去掉?
- yes or no对话框的问题
- 请问项目中的全局变量在哪里进行定义最好!
- 为什么我的aspx显示不出web forms controls
- 在UpdatePanel 里添加声音提示
- 数据备份的bak文件怎么还原啊?
FROM products as a inner JOIN xl_info as b
ON b.xl_id=a.p_xlid) ORDER BY a.p_browsecount DESC-.-!
select top 10 b.xl_id,b.xl_name
FROM products as a inner JOIN xl_info as b
ON b.xl_id=a.p_xlid ORDER BY a.p_browsecount DESC-.-!这个。。
select TOP 10 xl_info.xl_id,xl_info.xl_name FROM xl_info
where xl_info.xl_id in (select products.p_xlid from products group by products.p_xlid having count(products.p_xlid) > 1)
用group by having
读出来只有9条记录
SELECT distinct TOP 10 products.p_xlid FROM products,xl_info WHERE (xl_info.xl_id=products.p_xlid) ORDER BY products.p_browsecount DESC
)试一下
还要将结果按照xl_taxis DESC显示,最后显示还是11条 ORDER BY xl_taxis DESC
先取不重复的记录条数,然后select * from (不重复的记录ID) where ID in (不重复的记录ID)
ORDER BY 子句与 (products.p_browsecount) DISTINCT 冲突