SELECT * FROM <database>;
The * means = "Give me all the columns".
SELECT Expression: select the columns that you want.
SELECT name FROM cats;
Example:
SELECT name FROM cats;
SELECT name, age FROM cats;
SELECT cat_id, name, age FROM cats
//
The * means = "Give me all the columns".
SELECT Expression: select the columns that you want.
SELECT name FROM cats;
Example:
SELECT name FROM cats;
SELECT name, age FROM cats;
SELECT cat_id, name, age FROM cats
//
CODE: Introduction to WHERE
Select by age:
SELECT * FROM cats WHERE age=4;
Select by name:
SELECT * FROM cats WHERE name='Egg';
Notice how it deals with case:
SELECT * FROM cats WHERE name='egG';
//
CODE: Introduction to Aliases
- SELECT cat_id AS id, name FROM cats;
- SELECT name AS 'cat name', breed AS 'kitty breed' FROM cats;
- DESC cats;
//CODE: Updating Data
Change tabby cats to shorthair:UPDATE cats SET breed='Shorthair' WHERE breed='Tabby';Another update:UPDATE cats SET age=14 WHERE name='Misty';//CODE: DELETING DATA
- DELETE FROM cats WHERE name='Egg';
- SELECT * FROM cats;
- SELECT * FROM cats WHERE name='egg';
- DELETE FROM cats WHERE name='egg';
- SELECT * FROM cats;
- DELETE FROM cats;
No comments:
Post a Comment