I am constructing an inner join with php - below is the code that my php code resolves to:
SELECT * FROM comp-profile-01-general a INNER JOIN comp-profile-02-social b ON a.co_num = b.co_num INNER JOIN comp-profile-03-specialties c ON a.co_num = c.co_num WHERE a.co_num = 300023
I am getting the error: #1054 - Unknown column ‘a.co_num’ in ‘where clause’
SELECT
*
FROM
comp-profile-01-general AS a
INNER JOIN
comp-profile-02-social AS b
ON a.co_num = b.co_num
INNER JOIN
comp-profile-03-specialties AS c
ON a.co_num = c.co_num
WHERE a.co_num = 300023
When using an alias for a table the syntax is
table_name AS alias_name
Also do you need all fields from all three tables? If not just list the required fields only in the SELECT clause
you’ve put backticks around the tablename.columnname combo
so a.co_num is wrong, but a.co_num is right
a.co_num is also right, and it’s “best practice” not to use backticks at all, based on naming your tables and columns so that there is no need to use backticks