Inline queries - do more with the FROM clause
select *from (select sal as salary, comm as commission from emp) xwhere salary < 5000;
select *from (select sal as salary, comm as commission from emp) xwhere salary < 5000;
| SQL Structured Query Language. The most common language used for accessing relational databases. ![]() Custom Urban Dictionary Magnet by UrbanDictionary Get magnets at zazzle | ||
There is a plethora of SQL humor out there that center on the "0 rows returned" (i.e. "nothing found").
Here's a good example ... "clueless management".http://blog.drscottfranklin.net/2008/01/15/a-little-sql-humor/My preferred flavor of SQL is MySQL. Why? It comes with the web host I use most frequently. I'm not a SQL whiz. I know just enough to get by. Industrial SQL gurus - you probably have a million reasons why MySQL isn't that great, but for modest applications and on-the-side-hobby needs, MySQL is just right. It's easy to use with PHP and is ... well, priced "just right".
Also their site is a great resource of syntax and examples. For example, if you wanted to know everything you could ever do with the SELECT statement, you'll be blown away by this page.The "explicit join notation" uses the JOIN keyword to specify the table to join, and the ON keyword to specify the predicates for the join, as in the following example:
SELECT * FROM employee INNER JOIN department ON employee.DepartmentID = department.DepartmentID
The "implicit join notation" simply lists the tables for joining (in the FROM clause of the SELECT statement), using commas to separate them. Thus, it specifies a cross-join, and the WHERE clause may apply additional filter-predicates (which function comparably to the join-predicates in the explicit notation).
The following example shows a query which is equivalent to the one from the previous example, but this time written using the implicit join notation:
SELECT * FROM employee, department
The GROUP BY statement is used in conjunction with the aggregate functions to group the result-set by one or more columns.
| SELECT column_name, aggregate_function(column_name) FROM table_name WHERE column_name operator value GROUP BY column_name |
