forked from Arthurhiew/Classify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataManipulationQueries.sql
More file actions
76 lines (57 loc) · 1.98 KB
/
Copy pathdataManipulationQueries.sql
File metadata and controls
76 lines (57 loc) · 1.98 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
64
65
66
67
68
69
70
71
72
73
74
75
76
--users
--add
INSERT INTO `users` (`username`, `password`) VALUES
(:usernameInput, :passwordInput);
--edit
UPDATE `users`
SET `username`=:usernameInput, `password`=:passwordInput
WHERE `id`=:userIDInput
--remove
DELETE FROM `users` WHERE `username`=:usernameInput;
--playlists
--add
INSERT INTO `playlists` (`name`, `user`) VALUES
(:playlistNameInput, (SELECT `id` FROM `users` WHERE `name`=:usernameInput));
--edit
UPDATE `playlists`
SET `name`=:nameInput, `user`=(SELECT `id` FROM `users` WHERE `username`=:usernameInput)
WHERE `name`=:playlistNameInput
--remove
DELETE FROM `playlists` WHERE `name`=:playlistNameInput;
--songs
--add
INSERT INTO `songs` (`name`) VALUES
(:songNameInput);
INSERT INTO `artists` (`name`) VALUES
(:songArtistName);
INSERT INTO `song_artist_association` (`songID`, `artistID`) VALUES
((SELECT `id` FROM `songs` WHERE `name`=:songNameInput), (SELECT `id` FROM `artists` WHERE `name`=:songArtistName));
--edit
UPDATE `songs`
SET `name`=:songNameInput
WHERE `name`=:songNameOriginal
--remove
DELETE FROM `songs` WHERE `name`=:songNameInput;
--artists
--add
INSERT INTO `artists` (`name`) VALUES
(:artistNameInput);
--edit
UPDATE `artists`
SET `name`=:artistNameInput
WHERE `name`=:artistNaneOriginal
--remove
DELETE FROM `artists` WHERE `name`=:artistNameInput;
--add song to playlist
INSERT INTO `playlist_song_association` (`playlistID`, `songID`) VALUES
((SELECT `id` FROM `playlists` WHERE `name`=:playlistNameInput), (SELECT `id` FROM `songs` WHERE `name`=:songNameInput));
--delete from from playlist
DELETE FROM `playlist_song_association` WHERE
`playlistID`=(SELECT `id` FROM `playlists` WHERE `name`=:playlistNameInput) AND
`songID`=(SELECT `id` FROM `songs` WHERE `name`=:songNameInput);
--select playlist
SELECT * FROM `playlist_song_association` WHERE `playlistID`=(SELECT `id` FROM `playlists` WHERE `name`=:playlistNameInput);
--song search
SELECT * FROM `songs` WHERE `name`=:searchText;
--artist search
SELECT * FROM `artists` WHERE `name`=:searchText;