Reputation: 13
My query:
SELECT id, pl, ka, user, users.imie, users.id, users.nazwisko, users.klasa
FROM word
LEFT JOIN users ON word.user = users.id BY word.pl ASC
It gives me this 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
'BY word.pl ASC LIMIT 0, 30' at line 1
Upvotes: 1
Views: 977
Reputation: 29298
Missing Order
in Order By
ALSO Both tables have an id
column, so you need to call either/both users.id
and word.id
to avoid the ambiguous error:
SELECT users.id, word.id, pl, ka, user, users.imie, users.id, users.nazwisko, users.klasa
FROM word
LEFT JOIN users ON word.user = users.id
ORDER BY word.pl ASC
Upvotes: 3
Reputation: 8497
Add Order by clause
SELECT id, pl, ka, user, users.imie, users.id, users.nazwisko, users.klasa
FROM word
LEFT JOIN users ON word.user = users.id
ORDER BY word.pl ASC
Upvotes: 1