Reputation: 2653
here is an sql query:
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%"
Please help me to find the mistake =(
Upvotes: 0
Views: 30
Reputation: 77876
WHERE
should come after JOIN
per syntax. Your query should be
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%'
Upvotes: 1
Reputation: 6844
try as per below-
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%"
Upvotes: 1
Reputation: 1490
Your Syntax is incorrect. Where is never between from and joins
See https://dev.mysql.com/doc/refman/5.0/en/select.html
Upvotes: 1