all groups > sql server programming > july 2003 >
You're in the

sql server programming

group:

Query to find names in 2 tables


Re: Query to find names in 2 tables David Portas
7/23/2003 10:42:06 PM
sql server programming: SELECT *
FROM
(SELECT customernr, [name]
FROM Table1
UNION ALL
SELECT customernr, [name]
FROM Table2) X
WHERE [name] = 'Mary'

--
David Portas
------------
Please reply only to the newsgroup
--


Query to find names in 2 tables Danny Springer
7/23/2003 11:29:13 PM
Is there a possibility to find names in 2 tables with one query? The
tables are not related.
Table1:
CustomerNr int(4)
Name Varchar(70)

Table2:
CustomerNr int(4)
Name Varchar(70)



table1: 33 Danny
47 John
59 Mary

table2: 137 Peter
12 Mary
57 Chris

I am trying to create a query that get's 1 record if I query for
'Danny', and 2 records if I query for 'Mary'

Thank you in advance,
Danny Springer
Re: Query to find names in 2 tables Danny Springer
7/24/2003 12:04:51 AM
[quoted text, click to view]

Life can be so simple.............

Thank you for your fast answer.
Danny
AddThis Social Bookmark Button