hi, I'm very new to sql, and figure this should be a common question, but I've had little luck getting anywhere with tutorials etc.
I've three tables representing a many to many relationship, so let's say (using arbitary names);
create table people (
name varchar(70) not null primary key,
age integer)
create table tasks (
job varchar(100) not null primary key,
pay integer)
create table many2manylink (
index_PK integer not null primary key,
name varchar(70),
job varchar(100),
foreign key name references people(name),
foreign key job reference tasks(job))
How would I select all the ages of people who are getting paid a certain amount?
I was trying to hazard a guess by
select people.age from people inner join many2manylink on many2manylink.name = people name inner join tasks where tasks.pay = 500
but it wasn't getting me very far, and I was beginning to just take stabs in the dark.
Can anyone help break through this mental block?
thanks,
nik
ps Also, do the foreign keys play an important part in the selection process, or just to ensure that no unique fields are broken on data entry?