That would work if I needed to select a single column from a table. But if I need to select multiple values (c1, c2), then it wouldn't work. Can't have subquery with more than one column selected, in general, I think.
select * from (select case when 1=1 then (select c1, c2 from t1) else (select c1, c2 from t2) end); On Wed, May 11, 2011 at 9:34 PM, Woody & Yuni Ho <hwoody2w...@yahoo.com>wrote: > It won't work due to syntax. Try putting a select statement as the when > part of the case statement. > > > Woody wizard at large(I'm in shape. Round is a shape) > Connected by MOTOBLURâ„¢ on T-Mobile > > -----Original message----- > From: John <tauru...@gmail.com> > To: General Discussion of SQLite Database <sqlite-users@sqlite.org> > Sent: Wed, May 11, 2011 18:17:14 PDT > Subject: [sqlite] Can I dynamically select a table? > > So now I know that case can return column names. But is there a way to tell > it from which table to select. > Earlier I assumed that it is not possible. But know I requestioning > everything. > This, at least, has not worked: > > create table t1 (col integer); > create table t2 (col integer); > > select * from > (select case > when 1=1 > then t1 > else t2 > end); > > > Thanks. > > -- > ~John > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > -- ~John _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users