Summary


  • The SELECT statement has the following general form:

     
     SELECT  columns  FROM  tables  [WHERE  conditions  ] [GROUP BY  group  [HAVING  group_conditions  ]] [ORDER BY  sort_columns  ] [LIMIT  limits  ]; 
  • The clause select * retrieves all columns; select columnname retrieves a particular column.

  • We can specify tables as database.table and columns as table.column or database.table.column to avoid ambiguity.

  • Aliases are alternative names for tables and columns. Specify them this way:

     
     select  column  as  column_alias  from  table  as  table_alias  ; 
  • The WHERE clause is used to select rows matching search criteria.

  • The keyword DISTINCT removes duplicates from the result set.

  • The GROUP BY clause treats the rows retrieved group by group. Its chief use is in conjunction with group functions like count() .

  • The HAVING clause is like a WHERE clause for groups.

  • The ORDER BY clause sorts result rows according to the columns you specify.

  • The LIMIT clause is used to control which rows are returned from the total possible result set. You can specify the maximum rows returned and an offset from which to start.



MySQL Tutorial
MySQL Tutorial
ISBN: 0672325845
EAN: 2147483647
Year: 2003
Pages: 261

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net