On Fri, Apr 30, 2010 at 07:28:52AM -0700, David Lyon scratched on the wall:
> If I had a table called TABLE with fields P1N......P50N is there a way
> to select something like:
> 
> "select P%N from TABLE"

  SELECT * FROM...

>  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"

  If you don't want all of them, yes.  You can't use statement
  parameters on identifiers (names).

> I can obviously do it via scripting but wanted a more elegant way.

  I would strongly question the design of any database that has a
  structure like this. If this is supposed to be some kind of array,
  you should break the elements out into a different table and setup a
  One-to-Many relationship.  There are a few situations when something
  like this is justified, but those are rare.

  Having a well designed database will also make your queries a lot
  more straight-forward.

   -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"Our opponent is an alien starship packed with atomic bombs.  We have
 a protractor."   "I'll go home and see if I can scrounge up a ruler
 and a piece of string."  --from Anathem by Neal Stephenson
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to