Question

In: Computer Science

MySQL: What are the various SELECT statement clauses? Which ones are necessary and optional? How are...

MySQL: What are the various SELECT statement clauses? Which ones are necessary and optional? How are the results filtered using COMPARISON and LOGICAL OPERATORS? Give one of these operators examples. Describe how parentheses can influence a query result.

Solutions

Expert Solution

The following are the various SELECT statement clauses:

  • WHERE
  • GROUP BY
  • HAVING
  • ORDER BY
  • AS
  • FROM
  • SELECT

Every SELECT statement consists of SELECT and FROM clauses necessarily. Here, the role of the SELECT clause is to retrieve the columns from the particular table which is specified by the FROM clause.

Necessary clauses in SQL SELECT statement :-

These clauses are to present definitely to retrieve the required columns from the particular table.

The following are the Necessary clauses:-

  • SELECT
  • FROM

Optional clauses in SQL SELECT statement :-

These clauses are optionally used as per the requirement of the user in the SELECT statement. The columns can be retrieved even without the use of these clauses, hence they are optional.

The following are the Optional clauses:-

  • WHERE
  • GROUP BY
  • ORDER BY
  • HAVING
  • AS

Filtering using Comparison Operators :-

The Comparison Operators usually contain two operands, here both operands may be the attributes of the table or one of the operand might be a number which is used to compare with the attribute while retrieving the data from table.

For example, consider a table Student(name,id,percent). Retrieve the Student records with percentages greater than 70.

Query:- Select * from Student where percent > 70;

Filtering using Logical Operators :-

The logical operators usually retrieves the columns after verifying the condition as true or false.

The main logical operators in SQL are AND, OR, NOT.

For example, consider the table Employee(ename,eid,age,salary). Retrieve the Employee records whose age is greater than 30 and salary is equal to 10000.

Query:- Select * from Employee where age > 30 AND salary = 10000;

Parenthesis in SQL :-

The parenthesis plays major role when there is some calculation part in the query. The parenthesis adds additional priority while evaluating the query. It clearly indicates that the attributes or calculations with attributes within the parenthesis are evaluated first followed by the calculation of other statement.


Related Solutions

A subquery can select which of the following in MySQL? (Select all that apply) • A...
A subquery can select which of the following in MySQL? (Select all that apply) • A single row and a single column • Multiple rows with a single column • Mutiple rows and multiple colmns • A single row with multiple columns
Subject DataBase/MySQL What is wrong with this statement? SELECT vendor_id, (SELECT vendor_name FROM vendors), avg(invoice_total) FROM...
Subject DataBase/MySQL What is wrong with this statement? SELECT vendor_id, (SELECT vendor_name FROM vendors), avg(invoice_total) FROM invoices GROUP BY vendor_id; Select one: a. The subquery returns more than 1 row. b. You need a JOIN ON clause to pull from multiple tables. c. You cannot have a subquery in the SELECT statement. d. The result is a Cartesian Product. e. There is nothing wrong with this statement. What is wrong with this statement? SELECT vendor_name, avg(invoice_total) AS 'Invoice Total' FROM...
Subject - DataBase / MySQL * Which of the following is not correct about the statement...
Subject - DataBase / MySQL * Which of the following is not correct about the statement provided? SELECT Customer#, FirstName, LastName FROM Customers C JOIN Orders O ON C.Customer# = O.Customer# JOIN OrderItems OI ON O.Order# = OI.Order# JOIN Books B ON OI.ISBN = B.ISBN WHERE Category = 'Fitness' AND Category = 'Computers'; Select one: a. Joins the OrderItems table to the Books table using the field ISBN b. All of these are correct c. Joins the Customer table to...
Which of the following WHERE clauses could return the value “Ravnica” from the field SET? Select...
Which of the following WHERE clauses could return the value “Ravnica” from the field SET? Select one: a. WHERE SET = “Rav%”; b. WHERE SET LIKE “Rav_”; c. WHERE SET LIKE “%av”; d. WHERE SET LIKE “%R%i%”;
Discuss the various databases available in the GCU library. Which ones have you used before? What...
Discuss the various databases available in the GCU library. Which ones have you used before? What do you like about them? What do you not like about them?
Review the statements below and select the ones that correctly describe what a source document is....
Review the statements below and select the ones that correctly describe what a source document is. (Check all that apply.) Multiple select question. A source document is entered into an accounting information system regardless of its reliability in order to ensure completeness. An example of a source document can include sales receipts, invoices and checks. Accurate source documents are crucial to accounting information systems.
What are the different forms of radiologic imaging ~ which ones are for which functions? Be...
What are the different forms of radiologic imaging ~ which ones are for which functions? Be prepared to discuss the advantages and disadvantages of these digital imaging methods. (PET, MRI, Ultrasound, DEXA scan, PACS, functional MRI ~ difference between a functional MRI and a regular MRI). COURSE: Information Technology for the Health Professions
Select the financial statement of a publicly traded company. Analyze the various financing options the company...
Select the financial statement of a publicly traded company. Analyze the various financing options the company employed. What other options might you recommend? Why would you recommend them?
What information is necessary to review in order to be considered familiar with the Safe Select...
What information is necessary to review in order to be considered familiar with the Safe Select one or more: Handling, storage, and reactivity information Literature examples of use of the substance Identification and description of substance Hazard warnings Personal protection and first aid recommedations   How should spill cleaning materials be discarded? Select one: Leave them in the fume hood for the instructor. Rinse the cleaning materials in the sink, then place them in the trash can. Discard all components...
Describe how Landlord transfers risk to the tenant and what clauses you can expect to find...
Describe how Landlord transfers risk to the tenant and what clauses you can expect to find in that form.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT