-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic003.sql
More file actions
48 lines (28 loc) · 819 Bytes
/
basic003.sql
File metadata and controls
48 lines (28 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
SELECT * FROM student;
--Basic Queries -> getting specific pieces of informations
SELECT NAME from student;
SELECT name, major from student;
--in ascending order by default
SELECT name, major from student
ORDER BY name;
SELECT name, major from student
ORDER BY name DESC;
SELECT * FROM student
ORDER BY name DESC;
--two or more attributes in descending order
SELECT * FROM student
ORDER BY name, major DESC;
--limiting the numbert of results we get back
SELECT * FROM student
LIMIT 2;
SELECT * FROM student
ORDER BY student_id DESC
LIMIT 2;
--FILTERING DATA
-- <> not equals to (operator)
SELECT * FROM student
WHERE major <> 'science';
--check from a bunch of values if they are present
SELECT * FROM student
WHERE name IN ('Kate', 'nick', 'middleton') AND student_id > 2;
--Creating A DATABASE