tags:

views:

48

answers:

3

I have 2 MySql tables. users with id's and username's ; streams with userId's and streamId's How to get them as / join them into one table containing only username | streamId as SQL response? With one SQL query.

+2  A: 

you can do the following:

select a.username, b.streamId
from names a, streams b
where a.userId = b.userId;
noinflection
I think you might need a JOIN or something in there, but it seems like this would work.
MiffTheFox
Technically a comma between tables is a JOIN, its just old school syntax.
MindStalker
+2  A: 
select tb1.username, tb2.streamid 
from tb1
inner join tb2 on tb2.userid = tb1.userid

The response above returns the same results, just contains an implicit join which my be slower.

Nate Noonen
A: 
select u.username, max(s.streamId) as streamId
from users u
inner join streams s on u.id = s.userId
group by u.username
RedFilter