BrianFord
asked on
MySQL Query help
I have 2 tables joined by USERID:
TableA contains most of the details I need to select except for the
user's name, which I need to pull fom TableB
The problem is that TableB contains multiple records for each user and therefore when
I use something like:
select a.Col1
, a.Col2
, b.name
from TableA a
, TableB b
where b.userID = a.userID
I get wrong info returned because of the multiple user records in TableB
How can I gt the join to look at DISTINCT values only in TableB ?
TableA contains most of the details I need to select except for the
user's name, which I need to pull fom TableB
The problem is that TableB contains multiple records for each user and therefore when
I use something like:
select a.Col1
, a.Col2
, b.name
from TableA a
, TableB b
where b.userID = a.userID
I get wrong info returned because of the multiple user records in TableB
How can I gt the join to look at DISTINCT values only in TableB ?
Select *, (select name from table b where b.id = a.id) from a
ASKER
sorry, doesn't work: sub-query returns more than 1 row
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks very much,
Looks like this will work fine for me :)
Looks like this will work fine for me :)