tags:

views:

29

answers:

0

I have 3 tables and am trying to do something like the query below but that does not work:

SELECT * FROM tableA a if a.typ=0 then tableA-0 b else tableA-1 b end if where a.id = b.id

See what I am needing is if tableA typ is zero then pull from tableA-0 else pull from tableA-1.

This can not be 2 queries.

thanks

----Edit----

SELECT * FROM tableA a, tableA-0 aa, tableA-1 ab WHERE ( (a.typ=0 && a.id = aa.id) || (a.typ=1 && a.id = ab.id) )

That works just getting multiple records when searching for a specific a.id.

And the search continues... thanks

-- Edit : Solution if not needing each row but otherwise wont work --

SELECT distinct if(a.typ=0,aa.id,ab.id) as id FROM tableA a, tableA-0 aa, tableA-1 ab WHERE ( (a.typ=0 && a.id = aa.id) || (a.typ=1 && a.id = ab.id) )