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.

Recommended Answers

All 3 Replies

Something like this

SELECT url FROM amp WHERE name='LUNA';
select ar.url
from amp a
join ampref ar on a.amp_id = ar.amp_id
where a.name like 'luna'

Sorry my bad, didn't see ampref.code there

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.