0
SELECT users.name,
phone_info.phone_num,
FROM users LEFT OUTER JOIN phone_info
ON users.user_id = phone_info.user_id

I have 2 tables in my db users and phone_info. I want to use left join to execute the users who have numbers. However I get an error like this

Static analysis:

1 errors were found during analysis.

An expression was expected. (near "FROM" at position 43)
SQL query: Documentation

SELECT users.name, phone_info.phone_num, FROM users LEFT JOIN phone_info ON 
users.user_id = phone_info.user_id

MySQL said: Documentation

#1064 - You have an error in your SQL syntax; check the manual that 
corresponds to your MariaDB server version for the right syntax to use near 
'FROM users LEFT JOIN phone_info
ON users.user_id = phone_info.user_id' at line 3
2
  • 4
    get rid of the extra comma before FROM
    – Jen R
    Apr 20, 2017 at 16:37
  • When it tells you check "for the right syntax to use near..." the problem is generally the very last thing before that point. Since that thing by itself was valid syntax, but then the next thing you tried to do wasn't valid in that context.
    – David
    Apr 20, 2017 at 16:38

3 Answers 3

5

Get rid of the extra comma before FROM

SELECT users.name,
phone_info.phone_num
FROM users LEFT OUTER JOIN phone_info
ON users.user_id = phone_info.user_id
0

SELECT users.name, phone_info.phone_num FROM users LEFT OUTER JOIN phone_info ON users.user_id = phone_info.user_id ;I just removed that extra comma .try now I should work

0

The error explains it self.

An expression was expected. (near "FROM" at position 43); 

Because you have entered a comma(,) MySQL expects an expression after that. Just remove it.

Here's the query;

SELECT users.name,
phone_info.phone_num
FROM users LEFT OUTER JOIN phone_info
ON users.user_id = phone_info.user_id;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.