2014-11-17 15:39:27 +01:00
|
|
|
# Load Tables
|
|
|
|
CREATE TABLE IF NOT EXISTS students FROM TBL FILE 'test/students.tbl';
|
|
|
|
CREATE TABLE IF NOT EXISTS test FROM TBL FILE 'test/lin_xxs.tbl';
|
|
|
|
CREATE TABLE IF NOT EXISTS companies FROM TBL FILE 'test/tables/companies.tbl';
|
|
|
|
CREATE TABLE IF NOT EXISTS employees FROM TBL FILE 'test/tables/employees.tbl';
|
2014-11-17 22:13:29 +01:00
|
|
|
# SELECT
|
|
|
|
SELECT * FROM students WHERE grade <= 2.0;
|
|
|
|
# SUB-SELECT
|
2014-11-17 15:39:27 +01:00
|
|
|
SELECT name, city, grade FROM (SELECT * FROM students WHERE city = 'Potsdam') t1 WHERE grade <= 1.5 OR grade >= 3.5;
|
|
|
|
# GROUP
|
|
|
|
SELECT city, AVG(grade) AS average|, MIN(grade) AS best, MAX(grade) AS worst FROM students GROUP BY city;
|
|
|
|
# UNION
|
|
|
|
SELECT * FROM students WHERE grade = 1.3 UNION SELECT * FROM students WHERE grade = 3.7;
|
2014-11-26 00:26:20 +01:00
|
|
|
# JOIN
|
2014-11-26 12:19:33 +01:00
|
|
|
SELECT * FROM companies JOIN employees ON company_id = employee_company_id;
|
|
|
|
# INSERT
|
|
|
|
INSERT INTO students VALUES ('Max', 10101, 'Musterhausen', 3.3);
|