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!

Think it a JOIN problem?!

Status
Not open for further replies.

ChrisMacPherson

Programmer
Jul 3, 2000
157
GB
Hello all,

I have two tables, as below

msgTable userTable
======== =========
msgId userId userId userName
--------------- --------------------
0 4 4 'Foo'
1 4 5 'Bar'
2 5 6 'BarBar'

Right, I want to select certain msgs from my msgTable AND the associated userName from the userTable all in one go.
I think this should be possible, but cant quite work it out from the docs.

Thanks for any help! Chris MacPherson


 
Try this:

select msgTable.msgID, userTable.userID
from msgTable, userTable
where userTable.userID = msgTable.userID
order by msgTable.userID

There are many variants (eg. select * from ... when you want to select everything) and simplifications (eg. select.m.msgID .... from msgID m ....)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top