Reputation: 985
I've got a MySQL Database containing several tables and I've got to create a pretty complicated query to get the data I need from these tables, and I am having issues crating said query.
The tables are designed as so (the column names have been renamed, these arn't the actual columns),
Table1 id, name, rating, country
Table2 itemid, textbool1, textbool2
The query needs to:-
So far, I have this:-
SELECT table2.* from table2 INNER JOIN table1
WHERE table2.textbool1 = 'true' && table2.textbool2 = 'false'
&& table1.name LIKE 'test' && table1.rating >= '10' && table1.country = 'gb'
ORDER BY table1.rating DESC LIMIT 20
But this isn't working. Can anybody explain why?
Any help would be appriciated.
Edit
This query works: SELECT table2.* FROM table2 INNER JOIN table 2 ON(table2.item_id = table1.id) WHERE table1.country= 'de' && premiumservers.Rating >= 9 ORDER BY table1.Rating DESC LIMIT 20
But this does not: SELECT table2.* FROM table2 INNER JOIN tabel1 ON(table2.item_id = table1.id) WHERE table1.Name LIKE 'test' && table1.country = 'de' ORDER BY table1.Rating DESC LIMIT 20
Upvotes: 0
Views: 65
Reputation: 901
You are missing the ON
statement in INNER JOIN
Try this..
SELECT table2.* from
table2 INNER JOIN table1
ON( table2.itemid = table1.id )
WHERE table2.textbool1 = 'true' && table2.textbool2 = 'false'
&& table1.name LIKE '%test%' && table1.rating >= '10' && table1.country = 'gb'
ORDER BY table1.rating DESC LIMIT 20
Upvotes: 1