Combining two select queries?

To get the rows from table_1 that have no matches in the other tables you should use an OUTER JOIN instead of an INNER JOIN.

To get the rows from table_1 that have no matches in the other tables you should use an OUTER JOIN instead of an INNER JOIN: SELECT table_1. Id, table_1. Name, table_2.

Id, table_2. Name FROM table_1 LEFT JOIN table_3 ON table_3. Tbl1_id = table_1.

Id LEFT JOIN table_2 ON table_3. Tbl2_id = table_2. Id Result: table_1.

Id table_1. Name table_2. Id table_2.

Name 1 'tbl1_1' 1 'tbl2_1' 2 'tbl1_2' '' 3 'tbl1_3' 2 'tbl2_2' 3 'tbl1_3' 3 'tbl2_3' 4 'tbl1_4.

When using table_1 in the FOR clause and the two corresponding LEFT JOIN statements an ERROR 1066 is thrown. – Brook Julias Sep 8 '10 at 20:32 @Brook Julias: Error 1066 means Not unique table/alias. Avoid giving two tables the same alias and it should work.

I have tested the query on your table structure. The result I posted in my answer is a copy/paste of the result I got when testing the query. – Mark Byers Sep 8 '10 at 20:53.

How about: SELECT table_1. Id, table_1. Name, table_2.

Id, table_2. Name FROM table_3 INNER JOIN table_1 ON table_1. Id = table_3.

Tbl1_id INNER JOIN table_2 ON table_2. Id = table_3. Tbl2_id ORDER BY table_1.

Id, table_2.id.

The query using INNER JOIN returned the same as the query using LEFT JOIN. The only results returned were those contained in table_3. Leaving out some of the data in table_1.

– Brook Julias Sep 8 '10 at 20:16.

Changing the LEFT JOIN to RIGHT JOIN and the order in which the two joins appear in the query solved this problem. Here is a copy of the working code; SELECT table_1. Id, table_1.

Name, table_2. Id, table_2. Name FROM table_3 RIGHT JOIN table_2 ON (table_3.

Tbl2_id = table_2. Id) RIGHT JOIN table_1 ON (table_3. Tbl1_id = table_1.

Id) ORDER BY table_1. Name ASC, table_2. Name ASC.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions