Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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;
Posted
Updated 14-Jul-16 23:52pm

1 solution

I'd suggest a JOIN:
SQL
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900