On Fri, Apr 30, 2010 at 9:28 AM, David Lyon <david_ly...@yahoo.com> wrote:
> If I had a table called TABLE with fields P1N......P50N is there a way to 
> select something like:
>
> "select P%N from TABLE"
>
>  to return all the results from columns P1N......P50N or do I have to do it 
> manually:
>
> "select P1N, P2N, P3N, P$nN from TABLE"
>

use GLOB. See below

Last login: Wed Apr 28 09:42:46 on console
punk...@lucknow ~$sqlite3
-- Loading resources from /Users/punkish/.sqliterc
SQLite version 3.6.23
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE t(a);
sqlite> INSERT INTO t VALUES ('P1N');
sqlite> INSERT INTO t VALUES ('P3N');
sqlite> INSERT INTO t VALUES ('P30N');
sqlite> INSERT INTO t VALUES ('P303N');
sqlite> INSERT INTO t VALUES ('P303X');
sqlite> INSERT INTO t VALUES ('P30Z');
sqlite> SELECT * FROM t;
a
----------
P1N
P3N
P30N
P303N
P303X
P30Z
sqlite> SELECT * FROM t WHERE a GLOB 'P*N';
a
----------
P1N
P3N
P30N
P303N
sqlite>


> I can obviously do it via scripting but wanted a more elegant way.
>
> Thanks for your help in advance.
>
>
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
-----------------------------------------------------------------------
Assertions are politics; backing up assertions with evidence is science
=======================================================================
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to