SQL
Subqueries
SELECT firstname FROM persons WHERE salary > (SELECT AVG(salary) FROM persons WHERE gender = 'M')
Sql är ett frågespråk...
Förkortningar
- SQL - Structured Query Language
- PSQL - Postgre SQL
- SSMS - SQL Server Management Studio
- SSDT - SQL Server Data Tools
Filändelser
- .sql
Typer
Program
Kommentarer
-- En kommentar
Kommandon
SELECT
INSERT
UPDATE
REPLACE
DELETE
JOIN
INTO OUTFILE
FIELDS TERMINATED BY
ENCLOSED BY
LINES TERMINATED BY
Nyckel i SQL
PRIMARY KEY
Variabel i SQL
DECLARE @variabel INT
SET @variabel=1
Loop i SQL
WHILE condition
BEGIN
…
END
Funktion för att söka efter en tagg i SQL
FIND_IN_SET(key, haystack)
Operatorer
Operator | Beskrivning |
---|---|
= | Equal |
<=> | Equal (Safe to compare NULL values) |
<> | Not Equal |
!= | Not Equal |
> | Greater Than |
>= | Greater Than or Equal |
< | Less Than |
<= | Less Than or Equal |
IN ( ) | Matches a value in a list |
NOT | Negates a condition |
BETWEEN | Within a range (inclusive) |
IS NULL | NULL value |
IS NOT NULL | Non-NULL value |
LIKE | Pattern matching with % and _ |
EXISTS | Condition is met if subquery returns at least one row |
Reserverade ord, variabler och funktioner i MySQL (5.0.96)
Visa alla
- ADD
- ALL
- ALTER
- ANALYZE
- AND
- ASASC
- ASENSITIVE
- BEFORE
- BETWEEN
- BIGINT
- BINARY
- BLOB
- BOTH
- BY
- CALL
- CASCADE
- CASE
- CHANGE
- CHAR
- CHARACTER
- CHECK
- COLLATE
- COLUMN
- CONDITION
- CONSTRAINT
- CONTINUE
- CONVERT
- CREATE
- CROSS
- CURRENT_DATE
- CURRENT_TIME
- CURRENT_TIMESTAMPCURRENT_USERCURSOR
- DATABASE
- DATABASES
- DAY_HOUR
- DAY_MICROSECONDDAY_MINUTE
- DAY_SECONDDEC
- DECIMAL
- DECLARE
- DEFAULT
- DELAYED
- DELETE
- DESC
- DESCRIBE
- DETERMINISTIC
- DISTINCT
- DISTINCTROW
- DIV
- DOUBLE
- DROP
- DUAL
- EACH
- ELSE
- ELSEIF
- ENCLOSED
- ESCAPED
- EXISTS
- EXIT
- EXPLAIN
- FALSE
- FETCH
- FLOAT
- FLOAT4
- FLOAT8
- FOR
- FORCE
- FOREIGN
- FROM
- FULLTEXT
- GRANT
- GROUP
- HAVING
- HIGH_PRIORITYHOUR_MICROSECOND
- HOUR_MINUTE
- HOUR_SECONDIF
- IGNORE
- IN
- INDEX
- INFILE
- INNER
- INOUT
- INSENSITIVE
- INSERT
- INT
- INT1
- INT2
- INT3
- INT4
- INT8
- INTEGER
- INTERVAL
- INTO
- IS
- ITERATE
- JOIN
- KEY
- KEYS
- KILL
- LEADING
- LEAVE
- LEFT
- LIKE
- LIMIT
- LINES
- LOAD
- LOCALTIME
- LOCALTIMESTAMP
- LOCK
- LONG
- LONGBLOB
- LONGTEXT
- LOOP
- LOW_PRIORITYMATCH
- MEDIUMBLOB
- MEDIUMINT
- MEDIUMTEXT
- MIDDLEINT
- MINUTE_MICROSECONDMINUTE_SECONDMOD
- MODIFIES
- NATURAL
- NOT
- NO_WRITE_TO_BINLOGNULL
- NUMERIC
- ON
- OPTIMIZE
- OPTION
- OPTIONALLY
- OR
- ORDER
- OUT
- OUTER
- OUTFILE
- PRECISION
- PRIMARY
- PROCEDURE
- PURGE
- READ
- READS
- REAL
- REFERENCES
- REGEXP
- RELEASE
- RENAME
- REPEAT
- REPLACE
- REQUIRE
- RESTRICT
- RETURN
- REVOKE
- RIGHT
- RLIKE
- SCHEMA
- SCHEMAS
- SECOND_MICROSECONDSELECT
- SENSITIVE
- SEPARATOR
- SET
- SHOW
- SMALLINT
- SONAME
- SPATIAL
- SPECIFIC
- SQL
- SQLEXCEPTION
- SQLSTATE
- SQLWARNING
- SQL_BIG_RESULT
- SQL_CALC_FOUND_ROWSSQL_SMALL_RESULTSSL
- STARTING
- STRAIGHT_JOINTABLE
- TERMINATED
- THEN
- TINYBLOB
- TINYINT
- TINYTEXT
- TO
- TRAILING
- TRIGGER
- TRUE
- UNDO
- UNION
- UNIQUE
- UNLOCK
- UNSIGNED
- UPDATE
- USAGE
- USE
- USING
- UTC_DATEUTC_TIME
- UTC_TIMESTAMPVALUES
- VARBINARY
- VARCHAR
- VARCHARACTER
- VARYING
- WHEN
- WHERE
- WHILE
- WITH
- WRITE
- XOR
- YEAR_MONTHZEROFILL
Version av SQL
sql --version
Vilken SQL?
which sql
Sökväg
?
Länkar
Namn
- Maria
- My
Motsats
- NoSQL
Liknande
Liknande namn
- GraphQL
- JQL