这是一个SQL查询:
SELECT COUNT(*) FROM `actors` `t` WHERE company_name LIKE "%test%"
LEFT JOIN `actors_adresses` ON `actors`.id = `actors_adresses`.actor
AND `actors_adresses`.adress LIKE "%test2%"
请帮我找错误=(
答案 0 :(得分:1)
您的语法不正确。永远不会来自和加入
答案 1 :(得分:1)
按以下方式尝试 -
SELECT COUNT(*) FROM `actors` `t`
LEFT JOIN `actors_adresses` a ON t.id = a.actor
WHERE t.company_name LIKE "%test%"
AND a.adress LIKE "%test2%"
答案 2 :(得分:1)
WHERE
应该在每个语法JOIN
之后出现。您的查询应该是
SELECT COUNT(*)
FROM `actors`
LEFT JOIN `actors_adresses` ON `actors`.id = `actors_adresses`.actor
// You can leave this condition here as JOIN condition
AND `actors_adresses`.adress LIKE '%test2%'
WHERE `actors`.company_name LIKE '%test%'