- Home
- .NET coding challenges
- Add SQL JOIN types against multiple tables in SQL Server
Add SQL JOIN types against multiple tables in SQL Server
With a SQL statement, we can use the JOIN statement to join multiple tables to a database query.
Two commonly used JOIN types that are used in SQL Server are INNER JOIN and LEFT JOIN.
Take these users and roles data:
User
Id | Name | RoleId |
---|---|---|
1 | Dave | 1 |
2 | Roger | 2 |
3 | Pavan | 2 |
4 | Thierry | NULL |
Role
Id | Name |
---|---|
1 | Administrator |
2 | Editor |
Write a SQL statement that will return all users and their role. For table names, use User for the user table and Role for the role table. You'll need to use one of the JOIN methods to JOIN the User table with the Role table. Remember to only include the columns you need in the statement.
Give us your anonymous feedback regarding this page, or any other areas of the website.
Latest challenges
Convert hours, minutes and seconds into a time formatted string
Pass in the hours, minutes and seconds into a method and get it to return a time formatted string which should include leading zeros.
Contains online code editor
Work out the number of days between two dates
Write a C# function to work out the difference between two dates and return the number of days in this coding challenge.
Contains online code editor