UserName, UserID, FollowingUserID
'RachelLim', '1003', '1004'
'YunaKim', '1005', '1007'
'AustinLee', '1007', '1005'
'BenChoi', '1010', '1001'
'RebeccaFang', '1009', '1004'
'AliceAng', '1004', '1003'

Basically, i want to find rows in which userid = followinguserid. How do i do it using select?

  • Is UserID unique? – Vérace Oct 7 '19 at 1:01
  • i want to find rows in which userid = followinguserid Where these fields are to be equal? in ONE record? or you need a record pair where userid in one record is equal to followinguserid in another? – Akina Oct 7 '19 at 5:14
  • Please provide SHOW CREATE TABLE. – Rick James Oct 14 '19 at 19:06

You can use SELF JOIN to get result

select t1.* 
from my_table as t1
join my_table as t2 on t1.userid = t2.followinguserid

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.