SQL

SQL: 11 - SQL Example: Drupal 8 DB

Given 2 tables

node

nid    vid    type    uuid    langcode
1    1    article    aa17bdd2-2985-497f-be81-3a2b0db33f4b    en
2    2    article    06d1f1cf-a3bf-49ae-a190-7942bcbc8bf3    en
3    3    article    ee53ffc8-c395-427f-9b63-ecbcfe83bae0    en
4    4    article    3b329388-1c78-446f-a480-c66b162bef46    en
5    5    article    0c610060-746a-4f8a-acc8-6851f1929900    en

node_field_data

nid    vid    type    langcode    status    title    uid    created    changed    promote    sticky    revision_translation_affected    default_langcode
1    1    article    en    1    Home    1    1528950146    1528950157    1    0    1    1
2    2    article    en    0    Page1    1    1529046918    1529778699    1    0    1    1
3    3    article    en    0    Page2    1    1529046960    1529778699    1    0    1    1
4    4    article    en    0    Page3    1    1529046967    1529778699    1    0    1    1
5    5    article    en    0    Page4   
Tags

SQL: 08 - Operators

Operators


 

Operator

Description

=

Equal

<>

Not equal. Note: In some versions of SQL this operator may be written as !=

>

Greater than

<

Less than

>=

Greater than or equal

<=

Less than or equal

BETWEEN

Between an inclusive range

LIKE

Search for a pattern

IN

To specify multiple possible values for a column

Tags

SQL: 06 - JOIN and UNION

JOIN

JOIN tabulates columns from two or more tables WITH SAME NAMES

  • INNER JOIN: Returns all rows when there is at least one match in BOTH tables(default)

Tags

SQL: 04 - ALTER TABLE

ALTER TABLE

Syntax

 

Example

ALTER TABLE table_name AUTO_INCREMENT=1000

 

ADD

Syntax

ALTER TABLE table_name

ADD col_name varchar(255)

Tags

SQL: 03 - KEY and INDEX

PRIMARY KEY

Syntax

PRIMARY KEY (ID

 

Example

CONSTRAINT newIDCol PRIMARY KEY (ID,MediaColor)


 

FOREIGN KEY

Points to a PRIMARY KEY in another table

Tags

SQL: 02 - Constraints

CONSTRAINTS

In SQL, we have the following constraints:

  • NOT NULL - Indicates that a column cannot store NULL value

Tags
Subscribe to SQL