在sql server里可以这么写
select * from a where b_id where (select id from b)
找出a.b_id包含于b.id的a里的记录,但到了my sql里,就不支持了。我对mysql不怎么懂,有没有高手指点下路子,感激涕零!

解决方案 »

  1.   

    select * from a where b_id where (select id from b)
    select * from a where b_id in  (select id from b) ?
      

  2.   

    select * from a where exists (select * from b where b.id=a.b_id)
      

  3.   

    写错了,是where b_id in。
      

  4.   

    exists不行。
    有继续回答的吗?感激涕零!
      

  5.   

    select * from a where b_id in  (select id from b)
    这是正确的啊
      

  6.   

    可是在my sql里不行那 (access同样也不支持这种in法)
      

  7.   

    表结构就不用贴了吧,我
    select * from company where id in (select id from company)都报SQL语句错
      

  8.   

    select * from a where b_id in  (select id from b)
    我这里测试通过,不知道你那为什么报错select * from company where id in (select id from company)
    也是正确的你看看你那里select * from a报错不
      

  9.   

    select * from a不报错
    会不会是mysql版本低不支持呢?我用的是虚拟主机上的MySQL 4.0.14
      

  10.   

    mysql到4.1之后才支持子查询,联系空间商升级MySQL吧
      

  11.   

    有没有一条SQL能实现这个目的的写法呢?
    我是通过url传递SQL,多条的话不方便
      

  12.   

    那就改写一下,不用子查询,不过效率上会低一些,你试试这个:
    select distinct Atable.* from a Atable, b Btable where Atable.b_id = Btable.id