0% found this document useful (0 votes)
22 views

PHP Syntax

The document discusses various SQL commands used to query, manipulate, and manage data in databases and tables. It defines commands like SELECT, FROM, WHERE, AND, OR, BETWEEN, LIKE, IN, IS NULL, CREATE DATABASE, CREATE TABLE, CREATE INDEX, DROP DATABASE, DROP TABLE, DROP INDEX, UPDATE, DELETE, and ALTER TABLE and provides examples of how each command is used in a SQL query.

Uploaded by

Leon Tumandao
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

PHP Syntax

The document discusses various SQL commands used to query, manipulate, and manage data in databases and tables. It defines commands like SELECT, FROM, WHERE, AND, OR, BETWEEN, LIKE, IN, IS NULL, CREATE DATABASE, CREATE TABLE, CREATE INDEX, DROP DATABASE, DROP TABLE, DROP INDEX, UPDATE, DELETE, and ALTER TABLE and provides examples of how each command is used in a SQL query.

Uploaded by

Leon Tumandao
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

SELECT

SELECT allows you to define what data you want your query to return.
Ex: SELECT changes FROM patterns;

SELECT *
SELECT used with an asterisk (*) will return all of the columns in the table we're
querying.
Ex: SELECT * patterns;

FROM
FROM specifies the table we're pulling our data from.
Ex: SELECT changes FROM patterns;

WHERE
WHERE filters your query to only return results that match a set condition.
Ex: SELECT changes FROM patterns WHERE changes = ‘strip-tagin’;

AND
AND combines two or more conditions in a single query.
Ex: SELECT changes FROM patterns WHERE changes = ‘strip-tagin’ AND material = ‘Y-
polym’;

OR
OR is the same with AND but only one condition must be met.
Ex: SELECT changes FROM patterns WHERE changes = ‘strip-tagin’ OR material-A = 25;

BETWEEN
BETWEEN filters your query to return only results that fit a specified range.
Ex: SELECT changes FROM patterns WHERE material-A BETWEEN 25 AND 40;

LIKE
LIKE searches for a specified pattern in a column.
Ex: SELECT changes FROM patterns WHERE color LIKE ‘red’;

IN
IN allows us to specify multiple values we want to select for when using the WHERE
command.
Ex: SELECT changes FROM patterns WHERE color IN (‘red’, ‘green’, ‘white’);

IS NULL
IS NULL will return only rows with a NULL value.
Ex: SELECT changes FROM patterns WHERE color IS NULL;
IS NOT NULL
IS NOT NULL does the opposite it will return only rows without a NULL value.
Ex: SELECT changes FROM patterns WHERE changes IS NOT NULL;

CREATE DATABASE
CREATE DATABASE creates a new database.
Ex: CREATE DATABASE 3dPrintLib;

CREATE TABLE
CREATE TABLE creates a new table inside a database.
Ex: CREATE TABLE figurines (
M_id int,
name varchar(200),
material varchar(200),
M_amount int
);

CREATE INDEX
CREATE INDEX generates an index for a table.
Ex: CREATE INDEX idx_name ON figurines (name);

DROP DATABASE
DROP DATABASE deletes the entire database including all of its tables.
Ex: DROP DATABASE 3dPrintLib;

DROP TABLE
DROP TABLE deletes a table as well as the data within it.
Ex: DROP TABLE figurines;
DROP INDEX
DROP INDEX deletes an index within a database.
Ex: DROP INDEX idx_name;

UPDATE
The UPDATE statement is used to update data in a table.
Ex: UPDATE figurines SET M_amount = 45 WHERE name = ‘simon’;

DELETE
DELETE can remove all rows from a table.
Ex: DELETE FROM figurines material;

ALTER TABLE
ALTER TABLE allows you to add or remove columns from a table.
Ex: ALTER TABLE figurines
ADD pattern varchar(100);

ALTER TABLE figurines


DROP COLUMN material;

You might also like