May 28 2008
SQL select from two tables with the same field name
Running MySQL and doing join’ed queries you might run into problems when you try to get results from two tables into one results set, where both tables have a field that is identically named (common with id-fields). For example:
SELECT table1.id, table1.fieldA, table1.fieldB, table2.id, table2.fieldC, table2.fieldD
FROM `table1`,`table2`
WHERE table1.fieldA = ‘test’
AND table1.id = table2.fieldD;
Here […]
