我在我的网站上工作,我一直坚持编写MySQL查询,使用" LEFT JOIN"句法。我的查询的一个简单示例如下所示:
SELECT p.surname, f.f_path as players_image
FROM player p LEFT JOIN file f ON p.id_image = f.id_file
问题在于,我实际上使用了8个不同的表来获取必要的数据,并且我在WHERE
子句之后加入了它们(我发现这样做更容易):
SELECT p.surname, f.f_path as players_image
FROM player, file
WHERE p.id_image = f.id_file
我可以以某种方式修改第二个查询WHERE
子句以获得与第一个查询返回相同的结果吗?
我知道Oracle DB使用类似WHERE p.id_image(+) = f.id_file
的语法来管理它。它试图在MySQL数据库上但它给了我一个错误。
原始SQL查询(表名不同):
SELECT sp.id_speletajs, sp.vards, sp.uzvards, ss.numurs, f.f_path as attels, k.id_komanda, p.nosaukums as pozicija
FROM speletajs sp, fails f, speletaja_statistika ss, cempionata_komanda ck, komanda k, cempionats c, sezona s, pozicija p
WHERE
sp.id_attels = f.id_fails
and sp.id_speletajs = ss.id_speletajs
and ss.id_cempionata_komanda = ck.id_cempionata_komanda
and ss.id_pozicija = p.id_pozicija
and ck.id_komanda = k.id_komanda
and ck.id_cempionats = c.id_cempionats
and c.id_sezona = s.id_sezona
and k.mana_komanda = true
and s.nosaukums = (select max(s1.nosaukums) from sezona s1)