Im just putting together some queries however im sure i read somewhere that SQL supported some sort of conditional commands...
Basically what im trying to do is bring back a query that will always have:
ID
Association Type
Association Value
Now the association type relates to a table, so there could be 3 different tables, and association value will be a different column in each different table...
So is there a way in SQL to tell it what to select based on criteria... ie...
SELECT base_table.id, (if association_type == 1)assoc_table1.value1 AS association_value(else)assoc_table2.value2 AS association_value(/if)
WHERE base_table.id < 100
Thats psudo codey like stuff not a real SQL statement im just trying to show what i want to do, although i would ideally rather a switch() style statement rather than ifs, but im not fussy if it doesnt support it...
Its just if i cant select different tables based off certain criteria i would have to do a 2nd query for each row returned 🙁