Skip to content

jSQL Syntax

Rob Parham edited this page Oct 29, 2017 · 7 revisions

The jSQL.query method understands a subset of mySQL. It can parse and execute basic CRUD queries as well as DROP table queries.

jSQL ignores whitespace.

jSQL handles Prepared Statements and will replace question marks with values passed to the query's execute method.

jSQL ignores case except when dealing with table or column names or values.

jSQL permits the use of backticks (`) around table and column names, but they are not required.


SELECT Query syntax

SELECT
    [DISTINCT|DISTINCTROW|ALL]
    column_name [, column_name ...]
    FROM table
    [WHERE where_condition]
    [ORDER BY col_name [ASC | DESC], ...]
    [LIMIT row_count]

CREATE Query syntax

CREATE TABLE [IF NOT EXISTS] tbl_name (
    column name [ NULL | NOT NULL ] [ DEFAULT *default_value* ] [ [ AUTO_INCREMENT ] PRIMARY [ KEY ] | UNIQUE [ KEY ] ] ,...
    [PRIMARY KEY (column name, ...)],
    [UNIQUE KEY (column name, ...)],
)

UPDATE Query syntax

UPDATE table_name
    SET col_name1={expr1} [, col_name2={expr2] ...
    [WHERE where_condition]
    [ORDER BY ...]
    [LIMIT row_count]

INSERT Query syntax

INSERT [IGNORE] INTO tbl_name
    [(col_name,...)]
    VALUES (value,...)

DROP Query syntax

DROP TABLE tbl_name

DELETE Query syntax

DELETE FROM tbl_name
    [WHERE where_condition]
    [ORDER BY ...]
    [LIMIT row_count]

Clone this wiki locally