Forum Moderators: open
so in your last example you would........
SELECT 'bluetable' AS TableName, ID, column1
FROM bluetable
WHERE ID=UniqueID
UNION
SELECT 'redtable' AS TableName, ID, column1
FROM redtable
WHERE ID=UniqueID
Notice that the table that you are selecting from is "hard coded" as a string to be returned on every side of the UNION.
These tables:
bluetable
ID ¦ column1
-------------
1 ¦ 'blue text'
2 ¦ 'blue text2'
redtable
ID ¦ column1
-------------
1 ¦ 'red text'
2 ¦ 'red text2'
Would output:
Id ¦ column1 ¦ TableName
----------------
1 ¦ 'red text' ¦ 'redtable'
1 ¦ 'blue text'¦ 'bluetable'
2 ¦ 'red text2' ¦ 'redtable'
2 ¦ 'blue text2'¦ 'bluetable'
You can then use this line....
if ($TableName == 'bluetable') {echo "You are using bluetable"};
[edited by: Demaestro at 6:43 pm (utc) on Oct. 15, 2007]