日期:2014-05-18 浏览次数:20441 次
1:SELECT * FROM A,B WHERE A.ID=B.ID AND A.NAME='ASDF' 2:SELECT * FROM A INNER OUTER JOIN B ON A.ID=B.ID AND A.NAME='ASDF' 3:SELECT * FROM A WHERE A.ID=(SELECT ID FROM B WHERE NAME='ASDF')
2:SELECT * FROM A INNER JOIN B ON A.ID=B.ID AND A.NAME='ASDF' 3:SELECT * FROM B WHERE B.ID IN (SELECT ID FROM A WHERE NAME='ASDF') --这个结果字段是不同的
------解决方案--------------------
第二种是错误的,
SELECT * FROM A INNER JOIN B ON A.ID=B.ID AND A.NAME='ASDF'
------解决方案--------------------
SELECT * FROM A INNER JOIN B ON A.ID=B.ID WHERE A.NAME='ASDF' /*常规这个写法*/
------解决方案--------------------
用连接写法吧