



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




USE sql_store; SELECT FROM customers * WHERE ORDER stateBY first_name = ‘CA’ LIMIT 3;
—- This is a comment and it won’t get executed.
SELECT FROM customers (points * 10 + 20) AS discount_factor
—- Removing duplicates SELECT FROM customers DISTINCT state
SELECT FROM customers * WHERE state IN (‘VA’, ‘NY’, ‘CA’)
FROM WHERE customers points BETWEEN 100 AND 200
SELECT FROM customers * WHERE first_name LIKE ‘b%’
SELECT FROM customers * WHERE first_name REGEXP ‘^a’
More Examples —- WHERE Returns first_name customers REGEXP whose ‘ey$|on$’ first name ends with EY or ON —- —- Returnsor contains customers SE whose first name starts with MY WHERE first_name REGEXP ‘^my|se’ —- —- ReturnsR or U customers whose first name contains B followed by WHERE first_name REGEXP ‘b[ru]’
SELECT FROM customers * WHERE phone IS NULL
—- SELECT by their * first name (in descending order) FROM ORDER customers BY state, first_name DESC
SELECT FROM customers * LIMIT 3
SELECT FROM customers name, address UNION SELECT name, address FROM clients
INSERT VALUES INTO(‘Mosh’, customers(first_name, NULL, DEFAULT) phone, points)
—- INSERT Insert INTO multiple customers(first_name, single records phone, points) VALUES (‘Mosh’, NULL, DEFAULT), (‘Bob’, ‘1234’, 10)