Progo
Progo

Reputation: 13

#1064 - 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

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

Answers (3)

Tim Lewis
Tim Lewis

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

HaveNoDisplayName
HaveNoDisplayName

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

Kevin_Kinsey
Kevin_Kinsey

Reputation: 2300

You forgot ORDER:

ORDER BY word.pl ASC

Upvotes: 1

Related Questions