On Fri, Apr 17, 2009 at 11:33 PM, flakpit <gary.flakhe...@gmail.com> wrote: > > If anyone else has a moment and a concrete example instead of sending me to > tutorials, feel free to step in here. > > SELECT * FROM pubs ; I want ALL columns from the 'pubs' > table > > WHERE pub_title LIKE '%salem%' ; Where the title sounds like 'salem' > > In the pubs table, there is an ID field that points to the note in the > 'notes' table. I want to retrieve that note for the currently retrieved > record from the 'pubs' table and no other column in the 'notes table' > > In the pubs table, there is an ID field that points to the publisher in the > 'publisher' table. I want to retrieve that publisher for the currently > retrieved record from the 'publishers' table and no other column in the > 'publishers' table > > The query below retrieves the correct note and publisher for each retrieved > record in 'pubs' that sounds like 'salem' in the 'pub_title' but also every > other column in 'notes' and 'publishers' which I don't want. > > I just want the matching notes.note_note for each pubs record and not > notes.id or notes.idx etc. > I just want the matching publishers.publisher_name for each pubs record and > not publishers.id or publishers.idx etc. > > SELECT * FROM pubs > INNER JOIN notes > ON pubs.note_id=notes.note_id > INNER JOIN publishers > ON pubs.publisher_id=publishers.publisher_id > WHERE pub_title LIKE '%salem%' >
SELECT pubs.*, notes.note, publishers.publisher FROM pubs JOIN notes ON pubs.note_id = notes.note_id JOIN publishers ON pubs.publisher_id = publishers.publisher_id WHERE pubs.pub_title LIKE '%salem%' > I believe I explained myself well enough this time. You did. You should still do some SQL tutorials. In the meantime, I hope the above helps. > -- > View this message in context: > http://www.nabble.com/Slim-down-join-results-%28all-fields-returned%29-tp23098746p23109313.html > Sent from the SQLite mailing list archive at Nabble.com. > > _______________________________________________ > 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, Geospatial Data http://sciencecommons.org Nelson Institute, UW-Madison http://www.nelson.wisc.edu/ ----------------------------------------------------------------------- collaborate, communicate, compete ======================================================================= _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users