Basic multiple tables select q

Real beginner’s question I know. Really need an answer ASAP please :slight_smile:

Very standard situation: I have three tables which make up a many-to-many relationship. Table_1 and Table_2 contain the main data. Table_3 contains foreign keys from Table_1 and Table_2 linking them.

I’m after a SELECT command which selects all Table_1 rows which have links to particular value (say ‘3’) in Table_2.

command in English:
select all Table_1 rows which have a Table_2 ref of 3


Table_1
ref    int    primary key
....
....


Table_2
ref     int     primary key
....
....


Table_3
ref            int    primary key
table_1_ref    int    foreign key to table 1
table_2_ref    int    foreign key to table 2

thanks in advance

Anyone?.. please :slight_smile:

There’s enough info there to answer isn’t there? I think so.

SELECT table1.*
  FROM table1
INNER
  JOIN table3
    ON table3.table_1_ref = table1.ref
   AND table3.table_2_ref = 3

Many thanks r937 :slight_smile: Really appreciated.