Sql

SQL Syntax and PDO Operations

Overview of SQL Commands and PDO Operations

Create Database

Drop Database

Create Table

Datatypes

Datatype

Description

INT(n)

Integer values

FLOAT(n, d)

Decimal values

VARCHAR(n)

String with max number of characters

TEXT

String with without set limit (max value of 65,535)

DATE('YYYY-MM-DD')

Year, month, and day

DATETIME('YYYY-MM-DD HH:MI:SS')

Year, month, day, hour, minute, and second

TIMESTAMP('YYYY-MM-DD HH:MI:SS')

Datetime corresponding to UNIX epoch time

Constraints

Constraint

Description

PRIMARY KEY

Unique identifier

AUTO_INCREMENT

Integer value is automatically added and incremented

UNIQUE

Value must be unique

NOT NULL

Value cannot be NULL

DEFAULT

Initialized with default value

Table vorhanden

Alter Table

Drop Table

Select Rows

Select Distint Rows

Joins

Join

Description

(INNER) JOIN

Returns only matches from both tables

LEFT JOIN

Returns all entries from left table, and matches from right table

RIGHT JOIN

Returns all entries from right table, and matches from left table

FULL JOIN

Returns all entries from both tables

Aggregate Functions

Function

Description

COUNT(column)

Counts number of rows

SUM(column)

Adds all values

MIN(column)

Find the smallest value

MAX(column)

Find the largest value

AVG(column)

Find the average value

Conditions

Operator

Condition

=, !=

Equal, not equal

<, >,

Less than, greater than

<=, >=

Less/greater than or equal to

BETWEEN ... AND ...

Within range of two values

NOT BETWEEN ... AND ...

Not within range of two values

IN (...)

Exists in list

NOT IN (...)

Does not exist in list

LIKE

Case insensitive equality comparison

NOT LIKE

Case insensitive inequality comparison

%

Matches a sequence of characters

\_

Matches a single character

IS NULL

Value is null

IS NOT NULL

Value is not null

ANY (...)

If any values meet condition

ALL

If all values meet condition

EXISTS

If one or more records exist

Insert Rows

Update Rows

Delete Rows

PDO

Open Connection

Datatypes

Datatype

Description

PDO::PARAM_BOOL

Represents a boolean data type

PDO::PARAM_NULL

Represents the SQL NULL data type

PDO::PARAM_INT

Represents the SQL INTEGER data type

PDO::PARAM_STR

Represents the SQL CHAR, VARCHAR, or other string data type

Select Rows

Insert Row

Update Row

Delete Row

MySQL Dump

MySQL Dump mit praxisnahen Beispielen einfach erklärt

Export

Import

Prefix for all tables

How to add prefix of all tables in mysql

Last updated

Was this helpful?