-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasic SQL_Basic Query.sql
More file actions
63 lines (48 loc) · 1.23 KB
/
Basic SQL_Basic Query.sql
File metadata and controls
63 lines (48 loc) · 1.23 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
-- SELECT & FROM
SELECT * FROM Shinkansen_stations; -- menampilkan semua data
SELECT Station_Name from Shinkansen_stations; -- hanya menampilkan Station_Name
-- WHERE
SELECT * FROM Shinkansen_stations
where Distance_from_Tokyo_st = 293.6;
SELECT * FROM Shinkansen_stations
WHERE Station_Name = 'Atami';
-- AND, OR, NOT
SELECT *
FROM Shinkansen_stations
WHERE Year = '2003'
AND Prefecture = 'Tokyo'; -- AND
SELECT *
FROM Shinkansen_stations
WHERE Prefecture = 'Tokyo'
OR Prefecture = 'Aichi'; -- OR
SELECT *
FROM Shinkansen_stations
WHERE NOT Year = '1964';
-- LIKE
SELECT *
FROM Shinkansen_stations
WHERE Prefecture like 't%'; -- awalan huruf t
SELECT *
FROM Shinkansen_stations
WHERE Company like '%izu%'; -- huruf terdapat izu
-- ALIAS
SELECT Prefecture as Wilayah
from Shinkansen_stations;
SELECT
Station_Name as nama_stasiun,
Year as Tahun,
Distance_from_Tokyo_st as jarak_dari_tokyo
FROM Shinkansen_stations;
-- DELETE
DELETE FROM Shinkansen_stations
WHERE Station_Name='Station_Name';
-- ORDER BY
SELECT * FROM Shinkansen_stations
ORDER BY Station_Name ASC;
-- LIMIT
SELECT * FROM Shinkansen_stations
LIMIT 5;
-- OFFSET
SELECT * from Shinkansen_stations
LIMIT 5
OFFSET 1;