tblThings
=======================
ID | thing | typeID
=======================
1 | car | 1
2 | dog | 2
3 | phone | 1
tblTypes
==============
typeID | type
==============
1 | old
2 | new
What I want to do is to give columns different names in my SELECT statement depending on the type they are.
So rather than SELECT * FROM tblThings where all things old and new will be returned under the header "thing" I'd like to be able to do something like...
SELECT thing as oldthing or newthing
FROM tblThings a, tblTypes b
WHERE a.typeID = b.typeID
AND b.type = old or new
3 rows returned...
===================
oldthing | newthing
===================
car | NULL
phone | NULL
NULL | dog
Is there a better way to tackle this in one SQL statement?
Thanks,
Laeg
=======================
ID | thing | typeID
=======================
1 | car | 1
2 | dog | 2
3 | phone | 1
tblTypes
==============
typeID | type
==============
1 | old
2 | new
What I want to do is to give columns different names in my SELECT statement depending on the type they are.
So rather than SELECT * FROM tblThings where all things old and new will be returned under the header "thing" I'd like to be able to do something like...
SELECT thing as oldthing or newthing
FROM tblThings a, tblTypes b
WHERE a.typeID = b.typeID
AND b.type = old or new
3 rows returned...
===================
oldthing | newthing
===================
car | NULL
phone | NULL
NULL | dog
Is there a better way to tackle this in one SQL statement?
Thanks,
Laeg