Query - Select two tables where a.id=b.id

Hi,

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?

tnx.

Tom
info [ Fr, 28 Dezember 2007 08:05 ] [ ID #1895021 ]

Re: Query - Select two tables where a.id=b.id

info (informatyk [at] 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 [at] sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downlo ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books .mspx
Erland Sommarskog [ Fr, 28 Dezember 2007 09:33 ] [ ID #1895023 ]

Re: Query - Select two tables where a.id=b.id

Research information on joins. This includes inner joins, left outer join,
right outer join, full outer join and cross joins

--
Sincerely,
John K
Knowledgy Consulting, LLC
knowledgy.org

Atlanta's Business Intelligence and Data Warehouse Experts


"info" <informatyk [at] fitness[CUT]authority.pl> wrote in message
news:fl2785$f5k$1 [at] news2.task.gda.pl...
> Hi,
>
> 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?
>
> tnx.
>
> Tom
>
>
>
>
>
>
>
>
Knowledgy [ Mi, 09 Januar 2008 21:11 ] [ ID #1903554 ]
Datenbanken » comp.databases.ms-sqlserver » Query - Select two tables where a.id=b.id

Vorheriges Thema: Format Number on Select
Nächstes Thema: learner a ms sql