How to resolve ambiguous column names when retrieving results?
You can set aliases for the columns that you are selecting: $query = ‘SELECT news.id AS newsId, user.id AS userId, [OTHER FIELDS HERE] FROM news JOIN users ON news.user = user.id’
You can set aliases for the columns that you are selecting: $query = ‘SELECT news.id AS newsId, user.id AS userId, [OTHER FIELDS HERE] FROM news JOIN users ON news.user = user.id’
I think you’re looking for the UNION clause, a la (SELECT * from us_music where `genre` = ‘punk’) UNION (SELECT * from de_music where `genre` = ‘punk’)
SQL supports qualifying a column by prefixing the reference with either the full table name: SELECT tbl_names.id, tbl_section.id, name, section FROM tbl_names JOIN tbl_section ON tbl_section.id = tbl_names.id …or a table alias: SELECT n.id, s.id, n.name, s.section FROM tbl_names n JOIN tbl_section s ON s.id = n.id The table alias is the recommended approach — … Read more