Reputation: 17666
I have been reading this query now for about 20 minutes and I cannot see what is wrong with it.
SELECT SQL_CALC_FOUND_ROWS addressbook_people.first_name,
addressbook_people.last_name ,
addressbook_people.preferred_name ,
addressbook_companies3.name ,
addressbook_people.url ,
addressbook_groups5.name ,
addressbook_people.telephone1 ,
addressbook_people.telephone2 ,
addressbook_people.telephone3 ,
addressbook_people.email1 ,
addressbook_people.email2 ,
addressbook_people.fax1 ,
addressbook_people.fax2 ,
root_countries13.name ,
root_territories14.name ,
root_cities15.name ,
addressbook_people.address1 ,
addressbook_people.zip_postal1 ,
addressbook_people.po_box ,
root_countries19.name ,
root_territories20.name ,
root_cities21.name ,
addressbook_people.address2 ,
addressbook_people.zip_postal2
FROM addressbook_people
WHERE (
(
addressbook_people.first_name LIKE '%a%'
OR addressbook_people.last_name LIKE '%a%'
OR addressbook_people.preferred_name LIKE '%a%'
OR addressbook_companies3.name LIKE '%a%'
OR addressbook_people.url LIKE '%a%'
OR addressbook_groups5.name LIKE '%a%'
OR addressbook_people.telephone1 LIKE '%a%'
OR addressbook_people.telephone2 LIKE '%a%'
OR addressbook_people.telephone3 LIKE '%a%'
OR addressbook_people.email1 LIKE '%a%'
OR addressbook_people.email2 LIKE '%a%'
OR addressbook_people.fax1 LIKE '%a%'
OR addressbook_people.fax2 LIKE '%a%'
OR root_countries13.name LIKE '%a%'
OR root_territories14.name LIKE '%a%'
OR root_cities15.name LIKE '%a%'
OR addressbook_people.address1 LIKE '%a%'
OR addressbook_people.zip_postal1 LIKE '%a%'
OR addressbook_people.po_box LIKE '%a%'
OR root_countries19.name LIKE '%a%'
OR root_territories20.name LIKE '%a%'
OR root_cities21.name LIKE '%a%'
OR addressbook_people.address2 LIKE '%a%'
OR addressbook_people.zip_postal2 LIKE '%a%'
)
)
LEFT JOIN addressbook_companies AS addressbook_companies3
ON addressbook_people.company_id = addressbook_companies3.id
LEFT JOIN addressbook_groups AS addressbook_groups5
ON addressbook_people.group_id = addressbook_groups5.id
LEFT JOIN root_countries AS root_countries13
ON addressbook_people.country1 = root_countries13.id
LEFT JOIN root_territories AS root_territories14
ON addressbook_people.territory1 = root_territories14.id
LEFT JOIN root_cities AS root_cities15
ON addressbook_people.city1 = root_cities15.id
LEFT JOIN root_countries AS root_countries19
ON addressbook_people.country2 = root_countries19.id
LEFT JOIN root_territories AS root_territories20
ON addressbook_people.territory2 = root_territories20.id
LEFT JOIN root_cities AS root_cities21
ON addressbook_people.city2 = root_cities21.id
ORDER BY LTRIM(addressbook_people.url)DESC
LIMIT 0, 10
This is the output of my filter for a data table. So ignore the fact that i'm looking for like 'a'
I use PHPMyAdmin, when executing the SQL in a Query via the Web Management Console I receive the following error
1064 - You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'LEFT JOIN addressbook_companies AS addressbook_companies3 ON addr' at line 54
I've checked the line, it's the beginning of my joins. I don't see a problem.. Can someone please help? I've never been any good with SQL.
Upvotes: 1
Views: 77