Home >> FAQs/Tutorials >> SQL Server FAQ

SQL Server FAQs - Understanding SELECT Statements with Joins and Subqueries

By: FYIcenter.com

A collection of 17 FAQs on SELECT statements with joins and subqueries. Clear answers are provided with tutorial exercises on joining multiple tables with inner and outer joins; using subqueries with IN, EXISTS, and FROM clauses; using UNION operations. Topics included in this FAQ are:

  1. How To Join Two Tables in a Single Query?
  2. How To Write a Query with an Inner Join?
  3. How To Define and Use Table Alias Names?
  4. How To Write a Query with a Left Outer Join?
  5. How To Write a Query with a Right Outer Join?
  6. How To Write a Query with a Full Outer Join?
  7. How To Write an Inner Join with the WHERE Clause?
  8. How To Name Query Output Columns?
  9. What Is a Subquery in a SELECT Query Statement?
  10. How To Use Subqueries with the IN Operators?
  11. How To Use Subqueries with the EXISTS Operators?
  12. How To Use Subqueries in the FROM Clause?
  13. How To Count Groups Returned with the GROUP BY Clause?
  14. How To Return the Top 5 Rows from a SELECT Query?
  15. How To Return the Second 5 Rows?
  16. How To Use UNION to Merge Outputs from Two Queries Together?
  17. How To Use ORDER BY with UNION Operators

Please note that all answers and tutorials are based on MS SQL Server 2005. To follow tutorials in this collection, you should connect to SQL server as a regular user who has enough permissions to create table and insert date in "FyiCenterData". It is assumed that you are using the temporary database, FyiCenterData, created in previous tutorial collections. Some sample scripts require database tables created by other samples in the beginning of the collection.

For questions on SELECT statement basics and GROUP BY, see the previous FAQ collection.

(Continued on next topic...)

Related Articles:


Other Tutorials/FAQs:


Related Resources:


Selected Jobs: