This is a discussion on Help with using a field to join tables with ON() within the MySQL forums, part of the Database Server Software category; --> Hi all, thanks for taking the time... Here's a sample query: SELECT a.*, p.* FROM author_information a LEFT JOIN ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi all, thanks for taking the time... Here's a sample query: SELECT a.*, p.* FROM author_information a LEFT JOIN products p on (a.authors_id IN ( p.author_information_id ) ) p.author_information_id is a field comprised of multiple authors -- ie "2,34,41". I've also tried: SELECT a.*, p.* FROM author_information a LEFT JOIN products p on all (a.authors_id IN ( SELECT products.author_information_id from products where products.products_id = p.products_id)) Both are valid, but only return one author, not authors 2,34 & 41. Incidentally, I've also tried joining author_information to products, just a shot in the dark that didn't go anywhere either. Hard coding the values LEFT JOIN.....on ( a.authors_id IN ( 2,34,41 )) returns exactly what I'm looking for. Can anyone point me in the right direction? Thanks, |
| |||
| kevin wrote: > Hi all, thanks for taking the time... > > Here's a sample query: > > SELECT a.*, p.* FROM author_information a > LEFT JOIN products p on (a.authors_id IN ( p.author_information_id ) ) > > > p.author_information_id is a field comprised of multiple authors -- ie > "2,34,41". > > I've also tried: > SELECT a.*, p.* FROM author_information a > LEFT JOIN products p on all (a.authors_id IN ( SELECT > products.author_information_id from products where > products.products_id = p.products_id)) > > Both are valid, but only return one author, not authors 2,34 & 41. > Incidentally, I've also tried joining author_information to products, > just a shot in the dark that didn't go anywhere either. > > Hard coding the values LEFT JOIN.....on ( a.authors_id IN ( 2,34,41 )) > returns exactly what I'm looking for. > > Can anyone point me in the right direction? Thanks, http://del.icio.us/Captain_Paralytic/normalization |
| ||||
| On Dec 19, 2:48 pm, "Paul Lautman" <paul.laut...@btinternet.com> wrote: > kevin wrote: > > Hi all, thanks for taking the time... > > > Here's a sample query: > > > SELECT a.*, p.* FROM author_information a > > LEFT JOIN products p on (a.authors_id IN ( p.author_information_id ) ) > > > p.author_information_id is a field comprised of multiple authors -- ie > > "2,34,41". > > > I've also tried: > > SELECT a.*, p.* FROM author_information a > > LEFT JOIN products p on all (a.authors_id IN ( SELECT > > products.author_information_id from products where > > products.products_id = p.products_id)) > > > Both are valid, but only return one author, not authors 2,34 & 41. > > Incidentally, I've also tried joining author_information to products, > > just a shot in the dark that didn't go anywhere either. > > > Hard coding the values LEFT JOIN.....on ( a.authors_id IN ( 2,34,41 )) > > returns exactly what I'm looking for. > > > Can anyone point me in the right direction? Thanks, > > http://del.icio.us/Captain_Paralytic/normalization Hahaha, ok, I know this is bad design, but I'm not being paid for making his data better, I'm just doing a quickie module... And is this even possible? |