In screenshots and projects, projectId is the connector. I get the error below when I run the following sql code:
SQL Code:
SELECT * FROM screenshots s, projects p WHERE s.projectId == p.projectId ORDER BY s.idscreenshot DESC
Error:
A Database Error Occurred
Error Number: 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 ‘== p.projectId ORDER BY s.idscreenshot DESC’ at line 1SELECT * FROM screenshots s, projects p WHERE s.projectId ==
p.projectId ORDER BY s.idscreenshot DESCFilename:
C:\Workspace\htdocs\Jan-2012\nurbell\system\database\DB_driver.phpLine Number: 330
Does anybody know why this is happening?
It’s happening because the SQL equality operator is
=, not==.It’s also highly recommended to use explicit JOIN syntax to associate tables, rather than the implicit join syntax you’re using. So, for example, instead of:
You should use this: