编写查询以显示已填写配置文件详细信息的所有用户的名称和角色详细信息,按名称按升序排序 [英] Write a query to display the names and role details of all users who have filled in the profile details, sorted by name in ascending order
本文介绍了编写查询以显示已填写配置文件详细信息的所有用户的名称和角色详细信息,按名称按升序排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请回答以下问题?
我尝试过:
选择user.name,role.name from user,role,profile其中user.role_id = role.id和user.profile_id = profile.id和profile.id不是空订单
by user.name asc;
解决方案
我建议加入:
SELECT u.Name,r.Name FROM user u
JOIN 角色 r ON u.Role_id = r.id
JOIN profile p ON r.profileId = p.Id
ORDER BY u.Name ASC
带有配置文件的JOIN应该消除配置文件ID为空的行。
please give answer for the following questions?
What I have tried:
select user.name,role.name from user,role,profile where user.role_id=role.id and user.profile_id=profile.id and profile.id is not null order
by user.name asc;解决方案I'd suggest a JOIN:
SELECT u.Name, r.Name FROM user u JOIN role r ON u.Role_id = r.id JOIN profile p ON r.profileId = p.Id ORDER BY u.Name ASC
The JOIN with profile should eliminate rows where the profile ID is null.
这篇关于编写查询以显示已填写配置文件详细信息的所有用户的名称和角色详细信息,按名称按升序排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文