关于表关联时SQL效率的问题
一般两个表关联我知道常用的有以下三种方法
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'/*常规这个写法*/
[解决办法]
用连接写法吧