Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Shaper
Starting Member
8 Posts |
Posted - 2009-03-25 : 01:16:59
|
| Hi there,I have 2 select queries which create 2 tables which I then want to join into a single table.My first query is:SELECT core_relationship_concept_id_1, core_relationship_concept_id_2 FROM iaso_core_relationshipsWHERE core_relationship_concept_id_2 = 160845005 AND core_relationship_type = 160939001AND core_relationship_load = 51resulting in:102520001 160845005102517009 160845005160682003 160845005160683008 160845005160684002 160845005160685001 160845005160686000 160845005My second query is:SELECT core_relationship_concept_id_1, core_relationship_concept_id_2 FROM iaso_core_relationshipsWHERE core_relationship_concept_id_2 = 102509001 AND core_relationship_type = 116680003AND core_relationship_load = 51resulting in:102520001 102509001102517009 102509001160675002 102509001160674003 102509001160683008 102509001160684002 102509001160685001 102509001160677005 102509001What I want is to then get the list of values which appear in the left hand column of both tables i.e:102520001102517009160683008160684002How do I pack both selects into one SQL statement and then join them to get the above 4 data values? |
|
|
Shaper
Starting Member
8 Posts |
Posted - 2009-03-25 : 01:58:11
|
| Durr, I think I've solved it with:SELECT core_relationship_concept_id_1FROM iaso_core_relationshipsWHERE core_relationship_concept_id_2 = 160845005 AND core_relationship_type = 160939001AND core_relationship_load = 51INTERSECTSELECT core_relationship_concept_id_1FROM iaso_core_relationshipsWHERE core_relationship_concept_id_2 = 102509001 AND core_relationship_type = 116680003AND core_relationship_load = 51 |
 |
|
|
|
|
|