..<< = More Info = >>..

Wednesday, August 20, 2008

MySQL Basic Statement

The SQL SELECT Statement

  • The SELECT statement is used to select data from a table. The tabular result is stored in a result table (called the result-set).
  • SELECT column_name(s)
    FROM table_name
  • SELECT LastName,FirstName FROM Persons
The WHERE clause is used to specify a selection criterion.
  • The WHERE Clause
    To conditionally select data from a table, a WHERE clause can be added to the SELECT statement.
  • Syntax
    SELECT column FROM table
    WHERE column operator value
  • SELECT * FROM Persons
    WHERE City='Sandnes'
The INSERT INTO Statement
  • The INSERT INTO statement is used to insert new rows into a table.
  • Syntax
    INSERT INTO table_name
    VALUES (value1, value2,....)
  • INSERT INTO table_name (column1, column2,...)
    VALUES (value1, value2,....)
The Update Statement
  • The UPDATE statement is used to modify the data in a table.
  • Syntax
    UPDATE table_name
    SET column_name = new_value
    WHERE column_name = some_value
  • UPDATE Person SET FirstName = 'Nina'
    WHERE LastName = 'Rasmussen'
The DELETE Statement
  • The DELETE statement is used to delete rows in a table.
  • Syntax
    DELETE FROM table_name
    WHERE column_name = some_value
  • DELETE FROM Person WHERE LastName = 'Rasmussen'
  • Delete All Rows
    It is possible to delete all rows in a table without deleting the table. This means that the table structure, attributes, and indexes will be intact:
  • DELETE FROM table_nameorDELETE * FROM table_name

Source : w3schools.com

No comments:

Custom Search
 

Bursa 2000 | Find Better Jobs