I have 2 tables:
// table1
+
| col1 | id |
|
+
| test | 1 |
|
| test | 2 |
|
| anything | 3 |
|
| anything | 4 |
|
// table2
+
| col1 | id |
|
+
| test | 5 |
|
| test | 6 |
|
| anything | 7 |
|
| anything | 8 |
|
When I use union allto get values idwhere col1"test" is equal, the result is required:
select * from table1 where col1='test'
union all
select * from table2 where col1='test'
// the result of this code is: 4 rows. id{1,2,5,6}
Then, for faster and better performance, I implemented it with inner join, but the result is not needed:
select * from table1 t1 inner join table2 t2
on t1.col1=t2.col1
where t1.col1='test'
// the result of this code is: 8 rows. id{1-5,1-6,2-5,2-6}
How can I use inner joinwith these tables to get the result identifier {1, 2, 5, 6}?
EDIT
Example:
table1 {[col1]=word, [col2]=mean}
+-----+------------------------------------------------------------------------------------------+
| a | used when referring to someone or something for the first time in a text or conversation |
|-----|------------------------------------------------------------------------------------------|
| a | used to indicate membership of a class of people or things |
|-----|------------------------------------------------------------------------------------------|
| x | xxxxx |
+-----+------------------------------------------------------------------------------------------+
table2 {[col1]=word, [col2]=mean}
+-----+------------------------------------------------------------------------------------------+
| a | the blood group whose red cells carry the A antigen |
|-----|------------------------------------------------------------------------------------------|
| x | xxxxx |
+-----+------------------------------------------------------------------------------------------+
Now you can use join, and echoit?
a | used when referring to someone or something for the first time in a text or conversation
a | used to indicate membership of a class of people or things
a | the blood group whose red cells carry the A antigen
user4920811
source
share