打印

[数据库] 请问如何书写MYSQL语句

比如说:

先列出A=0的记录三条 再列出B=0的记录5条 一共是8条记录

请问如何书写MYSQL语句
where a=0 or b=0
?
你风流,我俊雅,和你同年少,两情深,罚下愿,再不去跳槽。
SELECT * from 表 where id in (SELECT top 8 id from 表 where id in (select id from 表 where A=0 or B=0 and id in(select top 3 id from 表 where A=0)))

看看行不行
语句太长了...有没有精简点的....

TOP

还在为头像烦恼?还在为不能关注好友动态烦忧?快来蓝色理想家园吧!
有没有精简点的....

TOP

使用union
修行的魔法师

TOP

比如说??

TOP

想精简,作视图吧,一下子搞定
[上海]专业承接网站开发[asp/php]与设计,域名空间租用,软件开发,软件销售……等业务与合作项目!
有意者请联系:QQ:89481372 MSn:alimoonzhang@hotmail.com

TOP

视图如何控制条件。。。

TOP

引用:
原帖由 文仔 于 2008-8-9 20:07 发表
SELECT * from 表 where id in (SELECT top 8 id from 表 where id in (select id from 表 where A=0 or B=0 and id in(select top 3 id from 表 where A=0)))

看看行不行
mysql里没有top只有limit
银子博客
经典站长QQ群:16719484
第三届经典论坛灌水王选举(12月1日-12月31日) 敬请期待

TOP

保持列名一致
select * from
(select 列名 from 表 where A=0 order by 字段 limit 3) as a
union
select * from
(select 列名 from 表  where B=0  order by 字段 limit 5) as b;
天津杰明工作室:www.022jm.com

TOP

楼上的方法可行...谢谢

as a  as b   好像没用哦....

TOP