我有两个用于oracle 11gr2的语句sql
SQL1:
Select * from tableA inpt, tableB ptbs
where inpt.z='A'
AND (inpt.pid = ptbs.pid
AND inpt.instcd = ptbs.instcd);
SQL2:
Select * from tableA inpt, tableB ptbs
where inpt.z='A'
AND inpt.pid = ptbs.pid
AND inpt.instcd = ptbs.instcd
Sql1比sql2快吗?
写作... and ... and ... and ...
慢慢写and (... and ... and (... and ... and ...))
?
类似于"或"?
答案 0 :(得分:1)
这里没有区别。
where inpt.z='A'
AND (inpt.pid = ptbs.pid
AND inpt.instcd = ptbs.instcd);
或
where inpt.z='A'
AND inpt.pid = ptbs.pid
AND inpt.instcd = ptbs.instcd
或
where inpt.pid = ptbs.pid
AND inpt.instcd = ptbs.instcd and inpt.z='A'
一切都是一样的。
答案 1 :(得分:0)
它可能只是写成:
SELECT *
FROM tableA inpt
INNER JOIN tableB ptbs
ON inpt.pid = ptbs.pid
WHERE inpt.instcd = ptbs.instcd
AND inpt.z = 'A'
这可能值得一看:INNER JOIN ON vs WHERE clause