Common MySQL Queries - dummies

By Steve Suehring, Janet Valade

Part of PHP, MySQL, JavaScript & HTML5 All-in-One For Dummies Cheat Sheet

To make a request that MySQL can understand, you build a SQL statement and send it to the MySQL server. The bold words in the table are the MySQL query names:

Statement Description
ALTER TABLE table
change
Makes changes to the table schema.
CREATE DATABASE database Creates a database.
CREATE TABLE (col
def,
. . .,PRIMARY
KEY(
col))
Creates a table.
DELETE FROM tablename
WHERE clause
Deletes data from a table.
DROP database|table Deletes a database or table.
INSERT INTO table
(col,col,. .
.
) VALUES (col,col,. .
.
)
Adds data to a table.
LOAD DATA
INFILE ″
filename″ INTO TABLE table
Adds data from a file to a table.
SELECT col,col,. . .FROM table WHERE
clause
Queries a table.
SHOW DATABASES|TABLES Displays information about a database or table.
SHOW COLUMNS FROM table Displays information about a table’s column.
UPDATE table SET col=value,. ..WHERE clause Changes data within a table.