Unix Technical Forum

Help with using a field to join tables with ON()

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


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 11:30 AM
kevin
 
Posts: n/a
Default Help with using a field to join tables with ON()

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,
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 11:30 AM
Paul Lautman
 
Posts: n/a
Default Re: Help with using a field to join tables with ON()

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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 11:31 AM
kevin
 
Posts: n/a
Default Re: Help with using a field to join tables with ON()

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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:38 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com