sql 查询问题

挺热 2008-04-02 12:41:18
SELECT bizid AS bid, bizid, biz_name, biz_cid, biz_photo, biz_intro, (SELECT COUNT(*) FROM kacol_bizuser WHERE bizid=bid and want=1) AS count FROM kacol_bizinfo ORDER BY count DESC

在 mysql5.0 下正常 在mysql 4.0 下就不可以
...全文
62 点赞 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
cuidenghong123 2008-04-04
join
回复
faisun 2008-04-03

SELECT i.*,count(u.*) as `count`

FROM kacol_bizinfo as i

left join kacol_bizuser as u on u.bizid=bid and u.want=1

ORDER BY count DESC
回复
faisun 2008-04-02
4.0 以下不支持子查询
回复
挺热 2008-04-02
不行啊
count(u.*) as count
这里一加上去就出问题
回复
faisun 2008-04-02
4.1 以上才支持子查询
你那个语句可以改为
left join 方法

SELECT i.*,count(u.*) as count

FROM kacol_bizinfo as i

left join kacol_bizuser as u on u.bizid=bid and u.want=1


ORDER BY count DESC

回复
挺热 2008-04-02
那用什么方法可以解决嘛 ?
回复
相关推荐
发帖
基础编程
创建于2007-09-28

2.1w+

社区成员

从PHP安装配置,PHP入门,PHP基础到PHP应用
申请成为版主
帖子事件
创建了帖子
2008-04-02 12:41
社区公告
暂无公告