Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saqibmehmoodgit/77cb4194289e99f0a0d34772815c12f4 to your computer and use it in GitHub Desktop.
Save saqibmehmoodgit/77cb4194289e99f0a0d34772815c12f4 to your computer and use it in GitHub Desktop.
user friends
userid name uid friendid
1 abc 1 2
2 def 1 3
3 xyz 2 3
4 ghf 3 4
where as uid and friendid in friends table are composite primary key and they are forign key from userid of user tabale .
question 1) when i have to insert into friends table than i will insert like "insert into friends(udi , friendid) values(1,2)" .
am i correct?
question 2) when i have to select frieds list for user 1 than query
"select f.name from user u outer join friends f on u.userid = f.friendid and f.uid =1 "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment