On Sun, Jun 05, 2011 at 12:47:47PM -0400, Sam Carleton scratched on the wall:

> In one select statement, I want to return a view of all the Invoice_Items
> for a particular Invoice such that there is one column that contains all the
> image names in one string:
> 
> Invoice_Item_Id | Invoice_Id | Description | Image Names
> ----------------+------------+-------------+----------------------
> 1               |   1        | CD          | Img1, Img2, Img3
> 
> Can I do this with SQL?

  As others have pointed out, you can, but that doesn't always make it
  a good idea.  If you're doing this just to turn around and split that
  value back up in your application code, you might want to rethink
  your data handling.  The data representation in the database is clear
  and correct.  Do you really want to alter that representation,
  smashing the image names together into a single, less clear value, just
  for the sake of making one query, rather than two?  Or even one query,
  but with an extra line or two of code in the parse function? 
  
  Why not just deal with values in their native, and more correct,
  "list of images" format?

   -j

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

"Intelligence is like underwear: it is important that you have it,
 but showing it to the wrong people has the tendency to make them
 feel uncomfortable." -- Angela Johnson
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to