I have a table with the name "order". There is a field with 1 character with the name adressFinder('*', '%', '+') in my table. If there is a '+' I want to Select the field "adress" from the table "customer". If there is a '%' I want to Select "adress" from the table "customerTwo" and if there is a '+' then select "adress" from the table "customerThree".
All tables can be joined with the field "customerID".
I tried something like this but doesnt work(syntax problem):
Select order.orderId, order.customerID,
CASE WHEN order.adressFinder = '*' THEN (SELECT customer.adress FROM customer INNER JOIN order on (customer.customerID = order.customerID))
WHEN order.adressFinder = '%' THEN (SELECT customer.adress FROM customerTwo INNER JOIN order on (customerTwo.customerID = order.customerID))
WHEN order.adressFinder = '+' THEN (SELECT customer.adress FROM customerThree INNER JOIN order on (customerThree.customerID = order.customerID))
END
FROM order
INNER JOIN customer on (order.customerID = customer.customerID)
INNER JOIN customerTwo on (order.customerID = customerTwo.customerID)
INNER JOIN customerThree on (order.customerID = customerThree.customerID)
Can somebody help me with my problem? Thank you!
Aucun commentaire:
Enregistrer un commentaire