Sunteți pe pagina 1din 2

SELECT: The select clause selects one or more fields from one or more tables.

For
example,

SELECT StdName

NOTE: USE ONLY FIELD NAMES IN THE SELECT STATEMENT (COLUMNS),


NOT TABLE NAMES OR OTHER SEARCH EXPRESSIONS.

SELECT*: Selects all fields of one or more tables


FROM: Specifies one or more tables that contain the fields in the select statement
WHERE: Narrows down the query to a specific record or records. For example, Find
student ID of student named Adam Smith

SELECT StudentID

FROM Student

WHERE StdName = Adam Smith

AND: Narrows down the query even further. Records that match both statements are
only displayed.

For example, find the address of the student whose name is John Smith and whose
major is economics

SELECT StdAddress

FROM Student

WHERE StdName = John Smith

AND StdMajor = Economics

OR: Narrows down the query even further. In this case records that match any one
of the statements is displayed. Find the student whose names are either john smith
or adam smith.

SELECT StdAddress

FROM Student

WHERE StdName = John Smith

AND StdMajor = Economics


ORDER BY: Orders the query result in ascending or descending alphabetical or
numerical order.

Select StdName
FROM Student

ORDER BY StdName ASC (for ascending) or DESC (for descending)

LIKE

LOGICAL OPERATORS <, >, >=, <=, <>, =: Used for mathematical operations

1. SQL is not case sensitive. Do not worry about upper or lower cases as long as
you have the spaces placed correctly
2. One common mistake while running SQL Query is misspelling the field name,
table name or criteria specification. Be sure to look into the tables and fields
before entering or running the query.
3. Always start a new statement from a new line, that is, click enter after
completing each query statement like, SELECT, FROM, WHERE.

S-ar putea să vă placă și