You are here: Re: Query - Select two tables where a.id=b.id « MsSQL Server « IT news, forums, messages
Re: Query - Select two tables where a.id=b.id

Posted by Erland Sommarskog on 12/28/07 08:33

info (informatyk@fitness[CUT]authority.pl) writes:
> my query is:
>
> SELECT a.symbol_art,b.node_key
>
> FROM artykuly a, art_podz b
>
> WHERE a.symbol_art=b.symbol_art
>
> ------------- -------------------
>
> table: artykuly table art_pod
>
> a.symbol_art b.symbol_art
>
> AA-0001 AA-0001 = record ok
>
> AA-0002 NULL = >>>>>>>>> I want to view diference
> records symbol_art in two tables
>
> How select all a.symbol_art where in table art_podz b.symbol_art is no
> exists?

You need to use an outer join:

SELECT a.symbol_art,b.node_key
FROM artykuly a
LEFT JOIN art_podz b ON a.symbol_art=b.symbol_art

With an outer join all rows in the table on the outer side, left here,
are maintained in the result set.



--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация