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)
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;
原来4.0是支持exists的..没用过4.0...
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
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)
from 表名 as a,tb as b
where a.nc_id=b.nc_id;
INNER JOIN
news_class B
ON A.nc_id =B.nc_id
where B.nc_id=2 or B.nc_fid=2