Jump to content

How to link three tables


lavercum

Recommended Posts

How to link three tables ?

two tables store int and the third text...

 

$requete = "SELECT table1.ID,table2.Tid,table3.text
INNER JOIN table2
ON table2.Tid=table1.ID
INNER JOIN table3 where text='$something'... ?
Thank's for help ! :facepalm:
Link to comment
Share on other sites

Classic Oracle syntax:

SELECT *FROM table1 t1, table2 t2, table3 t3WHERE t1.x = t2.xAND t2.x = t3.xAND any other desired limiting criteria

ANSI syntax:

SELECT *FROM table1 t1INNER JOIN table2 t2ON t1.x = t2.xINNER JOIN table3 t3ON t2.x = t3.xAND any other desired limiting criteria

The keyword AS can be omitted as shown above.

The queries above will display all columns. You can of course reduce this to a specific list of columns.

Note that each additional table must have a constraining equality which ties it to another table in the join.

Also these joins are inner joins -- which display only elements present in all tables -- there are other types of joins.

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...