mysql 4.0版本不支持$strSql = " select * from 表名 where nc_id in (select nc_id from news_class where nc_id=2 or nc_fid=2)";怎样修改,让它达到同样的目的?急求,谢谢。

解决方案 »

  1.   

    mysql 4.0 不支持子查询。可改为select * 
    from 表名 a 
    where exists (select 1 from news_class where nc_id=a.nc_id and nc_id=2 or nc_fid=2)
    进一步可改为
    select * 
    from 表名 a 
    where nc_id=2
    or exists (select 1 from news_class where nc_id=a.nc_id and nc_fid=2)
      

  2.   

    create temporary table tb select nc_id from news_class where nc_id=2 or nc_fid=2;select a.*
    from 表名 as a,tb as b
    where a.nc_id=b.nc_id;
      

  3.   

    原来4.0是支持exists的..没用过4.0...
      

  4.   

    select * from 表名 A
    INNER JOIN
    news_class B
    ON A.nc_id =B.nc_id 
    where B.nc_id=2 or B.nc_fid=2