-- CREATE DB/TABLES SHOWDATABASES; CREATEDATABASE our_database_name; USE our_database_name; CREATETABLE people (first_name VARCHAR(20), age INT); DESCRIBE people; -- CRUD INSERTINTO people (first_name, age)VALUES('Matt',34); SELECT age FROM people; SELECT*FROM people; UPDATE people SET weight =300WHERE first_name ='Bill'; DELETEFROM people WHERE first_name ="Bill"; -- OPERATORS SELECT*FROM people WHERE age !=63; SELECT*FROM people WHERE age <63; SELECT*FROM people WHERE age >63; SELECT*FROM people WHERE age >=63; SELECT*FROM people WHERE age <=63; SELECT*FROM people WHERE first_name first_name LIKE"%Charlie%"; SELECT*FROM people WHERE first_name NOTLIKE"%Charlie%"; SELECT*FROM people WHERE age ISNULL; SELECT*FROM people WHERE age ISNOTNULL; -- AND/OR SELECT*FROM people WHERE first_name ='Matt'AND age =43; SELECT*FROM people WHERE first_name ='Matt'OR age =49; -- ORDER SELECT*FROM people ORDERBY age DESC; SELECT*FROM people ORDERBY first_name DESC; SELECT*FROM people ORDERBY age ASCLIMIT2; SELECT*FROM people ORDERBY age ASCLIMIT2OFFSET1; SELECT*FROM people ORDERBY age DESC, first_name ASC; -- ALTER TABLE ALTERTABLE people ADDCOLUMN weight FLOAT; ALTERTABLE people DROPCOLUMN height; ALTERTABLE people MODIFYCOLUMN height FLOAT; ALTERTABLE people ADDCOLUMN height FLOATAFTER first_name; ALTERTABLE people MODIFYCOLUMN height FLOATAFTER age; ALTERTABLE people ADDCOLUMN id INTFIRST; ALTERTABLE people MODIFYCOLUMN height FLOATFIRST; ALTERTABLE people ADDCOLUMN dob DATETIME; ALTERTABLE people CHANGE dob date_of_birth DATETIME; ALTERTABLE people ADDCOLUMN id INTNOTNULLAUTO_INCREMENTPRIMARYKEYFIRST; -- AGGREGATION SELECTCOUNT(*), age FROM people GROUPBY age; SELECTSUM(salary), age FROM people GROUPBY age; SELECTAVG(salary), age FROM people GROUPBY age; SELECTMIN(salary), age FROM people GROUPBY age; SELECTMAX(salary), age FROM people GROUPBY age; SELECT GROUP_CONCAT(first_name), age FROM people GROUPBY age; SELECT GROUP_CONCAT(first_name), age, height FROM people GROUPBY age, height; -- JOINS SELECT*FROM people JOIN companies ON people.employer_id = companies.id; SELECT*from people JOIN companies; SELECT*FROM people RIGHTJOIN companies ON people.employer_id = companies.id; SELECT*FROM people LEFTJOIN companies ON people.employer_id = companies.id;