Tutorials
Help
 FAQ
 Object Browser
 Glossary
 About SkyServer
 EDR background
 How To
 - Search
 - Graph
 Download
Searching
 1. Introduction
 2. A Simple Query
 Practice
 3. Common Searches
 4. More Samples
 Practice
 5. Multiple Tables
 Practice
 6. Aggregate Fcns.
 7. Group By
 8. Order By
 Practice
 9. Views
 10. Functions
 Practice
 11. Conclusion

A Simple Query

An SQL query consists of three pieces, or blocks: the select block, the from block and the where block.

The select block tells the database which columns of data you want it to return. You must separate each column name with a comma. For example, if you wanted to find the celestial coordinates right ascension (ra) and declination (dec) of an object, the select block might read

select
ra, dec

The from block specifies which table (or tables) you want to search. If you wanted to retrieve information from the photoObj table, the from block would read

from
photoObj

The where block allows you to search for records with certain characteristics. Your list of characteristics must be separated by the word "AND". Suppose you wanted to limit your search to a patch of sky with ra between 0 and 3 degrees and dec between 0 and 1 degrees. To search only this patch of sky, your where block would read

where
ra BETWEEN 0 AND 3 AND
dec BETWEEN 0 AND 1

The database will return only those records that have an ra between 0 and 3 and a dec between 0 and 1.

This query is shown in the query window below. Click Submit to send the query to the database. When you see the results, scroll through them to verify that all records have ra between 0 and 3 and dec between 0 and 1.


Format HTML XML CSV
Enter your SQL query in the text box. The query is limited to 90 seconds and 1,000 rows.
The query you just submitted may take up to 90 seconds. Please wait until it finishes...