New to joins - Need help with query...

Reply

Join Date: Jun 2007
Posts: 16
Reputation: echobase is an unknown quantity at this point 
Solved Threads: 1
echobase echobase is offline Offline
Newbie Poster

New to joins - Need help with query...

 
0
  #1
Feb 5th, 2008
Hello-

I have these two tables:
  1. CREATE TABLE ampref (
  2. ampref_id SERIAL NOT NULL,
  3. amp_id INTEGER NOT NULL,
  4. code CHARACTER VARYING(255) NOT NULL,
  5. description TEXT
  6. );
  7. CREATE TABLE amp (
  8. amp_id SERIAL NOT NULL,
  9. name CHARACTER VARYING(255) NOT NULL,
  10. description CHARACTER VARYING(255),
  11. url CHARACTER VARYING(255)
  12. );
...and I'm trying to figure out how to run this query: For each ampref.code, if its amp.name = 'LUNA' find its url. I would appreciate any help on this thanks.
Last edited by peter_budo; Feb 5th, 2008 at 5:59 pm. Reason: Please use [code] tags
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,212
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 489
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: New to joins - Need help with query...

 
0
  #2
Feb 5th, 2008
Something like this
  1. SELECT url FROM amp WHERE name='LUNA';
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 523
Reputation: pty is on a distinguished road 
Solved Threads: 37
pty's Avatar
pty pty is offline Offline
Posting Pro

Re: New to joins - Need help with query...

 
0
  #3
Feb 5th, 2008
  1.  
  2. SELECT ar.url
  3. FROM amp a
  4. JOIN ampref ar on a.amp_id = ar.amp_id
  5. WHERE a.name LIKE 'luna'
Note to self... pocket cup
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,212
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 489
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: New to joins - Need help with query...

 
0
  #4
Feb 6th, 2008
Sorry my bad, didn't see ampref.code there
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC