SQL MYSQL Guide - Team-5/UserGuides GitHub Wiki

#Structured Query Language (SQL) Structured Query Language(SQL) is a language which handles databases. With the use of SQL one can access rows, columns, and tables inside the database. The command that accesses all of these elements is the SELECT command.

####The operand * stands for "all", so the first example above would select everything from the database "database", the second would select every value in the "name" column.

  • SELECT usage
    • SELECT * FROM database
    • SELECT name FROM database

####SQL allows one to create tables, delete rows, insert rows, drop tables, and specify certain conditions through a where command.

  • CREATE usage
    • CREATE TABLE "tablename"("Column1" "data_type", "Column2" "data-type", etc);
  • Between the parentheses are the columns or fields, for example:
    • "first_name" "TEXT" If one wanted to create a field named "first_name" this would be the format.

####The delete command must have a where to tell it which rows should be deleted, where allows conditional statements to narrow the results.

  • DELETE and WHERE usage

    • DELETE FROM table WHERE column1 = value
  • INSERT usage

    • INSERT into table (column1,..2,..3,etc) values(column1,..2,..3,etc
  • BUT it can also be used like so:

    • INSERT into table values(column1,..2,..3,..4). ####The first example allows one to pick and choose which columns they want to fill in, while the second forces the user to specify a value for each of the columns.

The drop command deletes the table from the database.

  • DROP usage
    • DROP TABLE tablename