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.
[SOLVED] Union query giving unexpected results
Moderator: General Moderators
-
impulse()
- Forum Regular
- Posts: 748
- Joined: Wed Aug 09, 2006 8:36 am
- Location: Staffordshire, UK
- Contact:
[SOLVED] Union query giving unexpected results
Last edited by impulse() on Tue Dec 11, 2007 4:14 am, edited 1 time in total.