-4

I have one table

ID    Details   User_id Last_ID
2960    ABC     52294
10532   PQR     61629   61629
11050   XYZ     69

and other

Id    UserName
69      aaaa
52294   bbbb
61629   cccc

Please provide a query to get following data

ID    Details   UserName last_id
Salil Lambay
  • 109
  • 1
  • 1
  • 6

4 Answers4

1

Query:

SELECT a.ID, a.details, b.UserName, a.Last_ID
FROM one_table as a,
INNER JOIN other_table as b ON b.id = a.user_id

see mysql join

Nijin22
  • 850
  • 13
  • 20
Pathik Vejani
  • 4,263
  • 8
  • 57
  • 98
0
SELECT d.ID, d.Details, u.UserName 
FROM details d, usernames u 
WHERE d.User_id = u.Id
mitkosoft
  • 5,262
  • 1
  • 13
  • 31
  • 1
    Please avoid posting answers with implicit join syntax, always teach users to use the proper syntax of joins! – sagi Feb 18 '16 at 11:03
0
select T1.id ,t1.details,t2.userName 
from t1
inner join t2 on t1.user_id =t2.id
Ankit Agrawal
  • 2,426
  • 1
  • 13
  • 27
0
select
    a.id,a.details,b.username
from
    first_table a,second_table b
where 
    a.userid = b.id
Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
Priyanshu
  • 885
  • 6
  • 12