>select * from a,b where a.id = b.id(+) and b.id is null</P>' C- _. k( F& S3 F2 U/ [+ [
>上边的好像是oracle的,我在SQL里边是这样写的</P>: S+ e8 S9 _' [' s3 f/ o
>select a.id ,b.* from a left join b on a.id=b.id where b.id is null</P>
>应该跟上边的是差不多的意思</P>
>我本来的意思是这样的写<BR>select * from a where aa.id not in (select id from b)<BR>或者: <BR>select id from a minus select id from b</P>- y2 A/ n0 C D7 V
>可是今天查阅了一下资料,说这样写的效率比较低,有人推荐了一种写法据说效率很高,但不知道在什么数据库上可用,我还没有测试过!<BR>select * from a,b where a.id = b.id(+) and b.id is null</P>- p" x s0 a5 \- I# s, q8 E
>希望有人测试后给个结果! <BR></P>
><br>我建了两个数据表,a和b, a 表中有id字段,b表中有id字段,查询语句是这样写的:<br>SELECT id<br>FROM a<br>WHERE id not in ( SELECT id FROM b)</P>
>但测试的时候出现如下错误:1064 You have an error in your SQL syntax near 'SELECT id FROM b)'at line 1</P>9 E \& v! _( ]) \
>另外我用select * from a,b where a.id = b.id(+) and b.id is null这种方法时也出现跟上面类似的错误,把(+)去掉后显示无数据,如果正确应该有数据的。</P>; k$ S( S+ M G/ |2 b
>这是什么原因?难道跟PHP(4)和MYSQL(3.23.56)版本有关?请高手给予指点。</P>
>MYSQL数据库我没有使用过!主要看它是不是支持select语句的嵌套使用!</P> ~+ l, P+ Z3 w2 E U
>你有没有试过select id from a minus select id from b的使用?</P>4 q2 i3 {! G5 q# i- P
>这里面主要是minus函数的使用,不知道MYSQL中是不是有这个函数,或者有同样功能的函数也可以使用在这里,你可以查看一下帮助!</P>
>不太清楚 </P>
| 欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) | Powered by Discuz! X2.5 |