union the rows from select 1 not in select 2?

2003-10-15 Thread Victor Spång Arthursson
Need to find out which rows from select 1 are not present in select 2, 
but is it possible to make som kind of union that only returns the 
overlapping rows from the two selects?

Sincerely

Victor

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: union the rows from select 1 not in select 2?

2003-10-15 Thread Hans van Dalen
for example:
Table1 contains: A and B and C
Table2 contains: B and C and D
all varchars
The query:
select A, B, C, '' as D from Table1
UNION
select '' as A, B, C, D from Table2
if the values are no varchar but for example smallints then you replace the 
'' with 0 or whatever wich value (eg NULL).

bye
hans van dalen
At 15:37 15-10-03 +0200, you wrote:
Need to find out which rows from select 1 are not present in select 2, but 
is it possible to make som kind of union that only returns the overlapping 
rows from the two selects?

Sincerely

Victor

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: union the rows from select 1 not in select 2?

2003-10-15 Thread Hans van Dalen
Of course,

But you still can see the table structure???

Hans

At 16:05 15-10-03 +0200, you wrote:

2003-10-15 kl. 15.51 skrev Hans van Dalen:

Table1 contains: A and B and C
Table2 contains: B and C and D
all varchars
The query:
select A, B, C, '' as D from Table1
UNION
select '' as A, B, C, D from Table2
if the values are no varchar but for example smallints then you replace 
the '' with 0 or whatever wich value (eg NULL).
Might be me beeing tired since its late afternoon, but doesnt the SQL 
above require that I know which rows are missing in the two tables?

What I want to do is to union the result

+---++---+
| id | betegnelse | enhed |
+---++---+
| 00046 | 838718001064311911 | 5 |
| 01330 | 537895001064317190 | 5 |
+---++---+
with

+---++---+
| id | betegnelse | enhed |
+---++---+
| 00046 | 838718001064311911 | 5 |
| 00120 | 641725001064311948 | 5 |
| 01330 | 537895001064317190 | 5 |
+---++---+
and have the new result

+---++---+
| id | betegnelse | enhed |
+---++---+
| 00120 | 641725001064311948 | 5 |
+---++---+
which is the row from select 1 thats not present in select 2…

Sincerely

Victor



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]