Skip to main content

Writing Basic Queries

  • Chapter
  • First Online:
SQL Primer
  • 2934 Accesses

Abstract

A query is an SQL statement that is used to extract a subset of data from your database and presents it in a readable format. As we have seen previously, the SELECT command is used to run queries in SQL. You can further add clauses to your query to get a filtered, more meaningful result. The level of flexibility afforded by SQL is one of the reasons it has succeeded as a query language. While there is an entire gamut of add-ons to SELECT, in this chapter we will focus on only two – ORDER BY and WHERE.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 16.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 16.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    If we let go of our from a table requirement, we can write a query with just SELECT. Try SELECT 1 in your DBMS and see the output.

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2018 Rahul Batra

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Batra, R. (2018). Writing Basic Queries. In: SQL Primer. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-3576-8_5

Download citation

Publish with us

Policies and ethics