dbTalk Databases Forums  

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

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Query - Select two tables where a.id=b.id in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
info
 
Posts: n/a

Default Query - Select two tables where a.id=b.id - 12-28-2007 , 01:05 AM






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









Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Query - Select two tables where a.id=b.id - 12-28-2007 , 02:33 AM






info (informatyk@fitness[CUT]authority.pl) writes:
Quote:
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 (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
  #3  
Old   
Knowledgy
 
Posts: n/a

Default Re: Query - Select two tables where a.id=b.id - 01-09-2008 , 02:11 PM



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@fitness[CUT]authority.pl> wrote

Quote:
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











Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.