- CREATE TABLE comments (
- content VARCHAR(100),
- created_at TIMESTAMP DEFAULT NOW()
- );
- INSERT INTO comments (content) VALUES('lol what a funny article');
- INSERT INTO comments (content) VALUES('I found this offensive');
- INSERT INTO comments (content) VALUES('Ifasfsadfsadfsad');
- SELECT * FROM comments ORDER BY created_at DESC;
- CREATE TABLE comments2 (
- content VARCHAR(100),
- changed_at TIMESTAMP DEFAULT NOW() ON UPDATE CURRENT_TIMESTAMP
- );
- INSERT INTO comments2 (content) VALUES('dasdasdasd');
- INSERT INTO comments2 (content) VALUES('lololololo');
- INSERT INTO comments2 (content) VALUES('I LIKE CATS AND DOGS');
- UPDATE comments2 SET content='THIS IS NOT GIBBERISH' WHERE content='dasdasdasd';
- SELECT * FROM comments2;
- SELECT * FROM comments2 ORDER BY changed_at;
- CREATE TABLE comments2 (
- content VARCHAR(100),
- changed_at TIMESTAMP DEFAULT NOW() ON UPDATE NOW()
- );
Saturday, February 22, 2020
TimeStamps
Subscribe to:
Post Comments (Atom)
Right Joins
-- OUR FIRST RIGHT JOIN (seems the same as a left join?) SELECT * FROM customers RIGHT JOIN orders ON customers.id = orders.custom...
-
CODE: Primary Keys Define a table with a PRIMARY KEY constraint: CREATE TABLE unique_cats ( cat_id INT NOT NULL , name ...
-
CODE: Setting Default Values Define a table with a DEFAULT name specified: CREATE TABLE cats3 ( name VARCHAR ( 20 ) DEFAUL...
-
SELECT MIN ( released_year ) FROM books ; SELECT MIN ( released_year ) FROM books ; SELECT MIN ( pages ) FROM books ; SELE...
No comments:
Post a Comment