|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
selecting rows from 2 tables
Hy, I have 2 tables each having 2 columns and containing certain numb of rows.
For eg. table A contains this row: 21282 | 22218 and table B contains this row: 21282 | 30006 I want to make a query so that the query return this row: 21282 | 22218 | 30006 That is it removes duplicate numbers. How to create this query thanks in advance |
|
#2
|
||||
|
||||
|
you would have to use 2 separate queries.
One query that pulls all the ID's from tableA that aren't in tableB and another query that pulls all the ID's from tableB that aren't in tableA Code:
// Get all the ID's from tableA that aren't in tableB SELECT [ID] FROM tableA WHERE tableA.ID NOT IN (SELECT [ID] FROM tableB) // Get all the ID's from tableB that aren't in tableA SELECT [ID] FROM tableB WHERE tableB.ID NOT IN (SELECT [ID] FROM tableA) then you could just combine the ID's and display them in numerical order. |
|
#3
|
|||
|
|||
|
Select TableA.Column1, TableA. Column2, TableB.Column2
FROM TableA INNER JOIN TableB ON TableA.Column1 = TableB.Column1; I believe that this is what you are after S- |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > selecting rows from 2 tables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|