mercredi 14 janvier 2015

Sqlite , how select data after "case when"

here is MyTbl1:



id (integer pk ai)
name (text char 25)
phone (int)


MyTbl2:



v1 (text char25)
v2 (text char 25)


i want make request like a:



select if exists id=1 in MyTbl1 if id=1 exists then select v1 from Mytbl2 if not exists return 0.


i try this:



select case when exists(select id from MyTbl1 where id=1) then (select v1 from MyTbl2) else 0 end;


its not working(


Aucun commentaire:

Enregistrer un commentaire