I'm a beginner in MySQL, so I need help. I want to get values of name
column from table role
to show it together with information from users
instead id_role
. How can I realize it? What should the query I write? Can you attach the link with solve?
The picture for explanation.
Read more here about SQL JOINS
SELECT users.*, role.*
FROM users
INNER JOIN role ON users.id_role = role.id;
尝试左加入
SELECT `users`.*,`role`.name as role FROM `users` LEFT JOIN `role` ON `users`.id_role= `role`.id
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.