[SOLVED] Union query giving unexpected results
Posted: Tue Dec 11, 2007 3:57 am
I've been asked to modify a script which has a union query to fetch data from 2 different tables. Both tables have different amount of columns with different names but essentially they store the same data. At the moment the query includes something like:
"SELECT something AS otherTablesColumnName"
so the union query works OK and it does work OK. But I'm being asked to include as column from table 1 which isn't in table 2. I've tried to trick MySQL into doing this by adding an extra column to table 2 named 'notused' then including:
'SELECT notused AS columnIWantFromTable1"
And this kind of works because it fetches the first character from the field in table 1 but nothing else. Could somebody explain why this happens please?
If you need more information I will be checking this thread regularly throughout the day.
"SELECT something AS otherTablesColumnName"
so the union query works OK and it does work OK. But I'm being asked to include as column from table 1 which isn't in table 2. I've tried to trick MySQL into doing this by adding an extra column to table 2 named 'notused' then including:
'SELECT notused AS columnIWantFromTable1"
And this kind of works because it fetches the first character from the field in table 1 but nothing else. Could somebody explain why this happens please?
If you need more information I will be checking this thread regularly throughout the day.