vendredi 6 janvier 2017

SELECT data from Table3 in case Table1.field='x' else SELECT data from Table2

This must be a rather simple task, have been playing around with SELECT IF / ELSE and CASE, in combination with a JOIN of all tables but so far no result...

SITUATION:

Table1 contains a lot of information on different kinds of material, in this case cars, trailers and various. All have brands, but when updating the 'brand' field of Table1 it should only offer certain options depending on the kind of material stored in Table1.Kind ...

Table2, Table3 & Table4 is just a 1 column option list of allowed brands (with no relation to Table1) where Table2 contains the car brands, Table3 the trailer brands and Table4 the various brands.

WHAT IS EXPECTED?

Depending on the value of Table1.Kind, I want to select all available brand options from Table2 or Table3 or Table4 to present them in Table1.Brand

Non-SQL example:

IF Table1.Kind=('car' OR 'motorhome') then SELECT * FROM Table2

IF Table1.Kind='trailer' then SELECT * FROM Table3

ELSE SELECT * FROM Table4

Aucun commentaire:

Enregistrer un commentaire