Jump to content

match 3 foreign_key on 4 tables


abahaedini

Recommended Posts

I have 4 tables:

table_1:Name       id_table_1               value  ---------|-----------------------|--------------------|----------------------DATA      5                              book table_2:Name         id_table_2		  value                Foreign_ id_table_1--------|--------------------|----------------------|-----------DATA		 12                      compueter		5 table_3:Name       id_table_3		  value                    Foreign_id_table_2---------|-------------------|-------------------------|----------------------------------DATA      14                      programming         12 table_4:Name	  id_table_4            value                        Foreign_id_table_3--------|----------------------|--------------------------|--------------------------------DATA      20                       Leran SQL                14

Now, I have 3 values: id_table_1,id_table_2,id_table_3 how can I select the value of table_1 with least query? note: i wana be sure parent is table_4 and tab;e_3 and table_2 is true! i wrote a code:

<select value form table_1jjoin_inner table_2jjoin_inner table_3join_inner table_4whereForeign_id_table_3 == id_table_3andForeign_id_table_2 == id_table_2andForeign_id_table_1 == id_table_3 

it's true or not?

Edited by abahaedini
Link to comment
Share on other sites

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...