Just looking for some help with this, i'm sure it is incredibly simple but after so many hours doing other areas of my site, i'm going a bit batty.
I just have a gaming competition whereby I have a table called 'leaders' that has only these columns:
fk_memberid | points_total
Quite simple. Then I have this query I found elsewhere on this forum to just get the rankings of each member.
SELECT
fk_memberid,
points_total,
(SELECT COUNT(*)+1 FROM leaders WHERE points_total>x.points_total) AS rank_upper,
(SELECT COUNT(*) FROM leaders WHERE points_total>=x.points_total) AS rank_lower
FROM
`leaders` x
My question is, how do I link the fk_memberid column to another table called "members" to the corresponding column "k_memberid"? I do this all the time of course but for some reason i'm struggling in this case due to the different type of query i'm familiar with above.
Sorry for the likely incredibly easy answer. Appreciate the help.
Do one thing SELECT * FROM Table1 T1, Table2 T2 WHERE T1.column_name = T2.column_name AND Another_comditio(if you want); may be it will help you
A quick example here:
SELECT l.fk_memberid, l.points_total, m.first_name FROM leaders l
left join member m
on m.k_member_id=l.fk_member_id
WHERE ...
This will give you back a table with 3 columns, 2 from leader table and "first_name" (assuming it exists) from member table
选择*从领导者LEFT JOIN成员成为members.k_memberid = Leaders.fk_memberid
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.