Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting all columns from A table & specific columns from B table

Status
Not open for further replies.

vb7

Programmer
Dec 20, 2002
1
UA
hi all,

I am writing simple SQL query to join 2 tables A and B.
SELECT * FROM A,B WHERE A.Id=B.Id

How can I select all the columns from A table and only selected ones from B table.
I do not want to write all the column names since they are quite large.
Is their any way to do this ?
(Something like SELECT A.*, B.<column-name> FROM A,B WHERE A.Id=B.Id)

thanx in advance
VB
 
The solution you suggested in your post worked for me in DB2. Did you try it on your database? This is what I did:

select org.*, opr.org_type, opr.end_dt
from pfmc.nvt_org org,
pfmc.nvt_org_pkge_rel opr
Where org.org_id = opr.org_id
and opr.end_dt is null
 
Good Morning, more fun and games ...

&quot;How can I select all the columns from A table and only selected ones from B table.&quot;

What you really want is a LEFT OUTER JOIN on table A.

While not all DBMSs are ANSI compliant, I'm sure this example is RTM.




AA 8~)
 
AA, you are just way too quick for your own good sometimes (i'm guilty of that too)

VB7 was on the right track, and pruSQLer confirmed it

inner, outer, full, cross, or natural -- makes no difference to the question asked

:)

rudy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top