Fill This Form To Receive Instant Help
Homework answers / question archive / Select one of the following SQL statements
Select one of the following SQL statements. You need to identify the statement and the syntax. Provide an example of the SQL statement using a table and attributes from the database you are designing for your data management project.
Select with Where clause
Select with Order by clause
Customers PK CustomerRental Rental Customer_id PK,FK1 Customer_id PK Customer_First_Name PK,FK2 Rental_id FK1 Customer_id Customer_Last_Name Rental_id FK2 Vehicle_id Gender Date_out DoB Return_Date Occupation Telephone_Number Customer_Address Email Vehicle PK Agency PK Agency_id Agency_Location Vehicle_id Vehicle_Class_id VehicleAgency PK,FK1 Vehicle_id PK,FK2 Agency_id Vehicle_Agency_id Vehicle_status Vehicle_Registration number Vehicle_Registration number Vehicle_Class PK Class_id Vehicle_Class Rental_Date
I have chosen the Select with Where clause in order to fully explain it.
The statement is: Select with Where Clause
The full syntax is:
SELECT <attribute_names_seperated_by_comma> FROM <table>
WHERE <condition>
The Select operation is used to select a subset of the tuples from a relation (table) based on a condition. Conditions act as filters in order to keep only the wanted tuples in the table that satisfy the conditions. Condition are based on one of the following formats:
<attribute_name1> <comparison> <constant value>
<attribute_name1> <comparison> < attribute_name2>
Having <comparison> = { = , < , <= , > , >= , !=}
To add, the logical operators, (AND, OR, NOT) can be combined too for multiple conditions.
Let us take an example from the designed database:
For the first example, we want to select the customer’s first names that have as last names “Will”. The query in order to perform such action is the following:
SELECT Customer_First_Name FROM Customers
WHERE Customer_Last_Name = “Will”
The second query will select the customer’s first and last names that are born before 1992. The query in order to perform such action is the following:
SELECT Customer_First_Name, Customer_Last_Name FROM Customers
WHERE DoB < “1-1-1992”