User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 428,634 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,987 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums
Views: 403 | Replies: 3
Reply
Join Date: Jun 2007
Posts: 16
Reputation: echobase is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
echobase echobase is offline Offline
Newbie Poster

New to joins - Need help with query...

  #1  
Feb 5th, 2008
Hello-

I have these two tables:
CREATE TABLE ampref (
    ampref_id serial NOT NULL,
    amp_id integer NOT NULL,
    code character varying(255) NOT NULL,   
    description text    
);
CREATE TABLE amp (
    amp_id serial NOT NULL,
    name character varying(255) NOT NULL,
    description character varying(255),    
    url character varying(255)
);
...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 4:59 pm. Reason: Please use [code] tags
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,471
Reputation: peter_budo is a jewel in the rough peter_budo is a jewel in the rough peter_budo is a jewel in the rough peter_budo is a jewel in the rough 
Rep Power: 11
Solved Threads: 296
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...

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

If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Reply With Quote  
Join Date: Oct 2005
Location: Manchester, UK
Posts: 482
Reputation: pty is on a distinguished road 
Rep Power: 3
Solved Threads: 33
pty's Avatar
pty pty is offline Offline
Posting Pro in Training

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

  #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'
  6.  
Note to self... pocket cup
Reply With Quote  
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,471
Reputation: peter_budo is a jewel in the rough peter_budo is a jewel in the rough peter_budo is a jewel in the rough peter_budo is a jewel in the rough 
Rep Power: 11
Solved Threads: 296
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...

  #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)

If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MySQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MySQL Forum

All times are GMT -4. The time now is 12:54 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC