Reputation: 641
I got this query:
SELECT companies_comments.id as id,
companies_comments.post as post,
companies_comments.comment as comment,
companies_comments.date as date,
companies.`id` AS company,
companies.`name` as name,
companies.`username` as username,
companies.`photo` as photo,
companies.`status` AS company_status
LEFT JOIN companies ON companies.id = companies_comments.company
WHERE company_status NOT IN (3,4)
AND companies_comments.post =1
The error: Error Code: 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 companies ON companies.id = companies_comments.company WHERE compa' at line 10
Error 1064 unexpectedly. Just tried with no ` , same results. No missing column. What can be happening?
Upvotes: 0
Views: 78
Reputation: 348
You haven't added FROM what table.You have missed the from part.
Example:
SELECT *
FROM table1
LEFT JOIN table2
ON table1.column_name=table2.column_name
Upvotes: 0
Reputation: 24815
You're missing the tablename and also a FROM
section in the query
SELECT companies_comments.id as id,
companies_comments.post as post,
companies_comments.comment as comment,
companies_comments.date as date,
companies.`id` AS company,
companies.`name` as name,
companies.`username` as username,
companies.`photo` as photo,
companies.`status` AS company_status
FROM companies, companies_comments
LEFT JOIN companies ON companies.id = companies_comments.company
WHERE companies.company_status NOT IN (3,4)
AND companies_comments.post =1
Upvotes: 1