Repository navigation
Expand file tree
/
Copy pathQueryStuff.txt
More file actions
46 lines (31 loc) · 2.08 KB
/
Copy pathQueryStuff.txt
File metadata and controls
46 lines (31 loc) · 2.08 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
//pass a letter or number (replace a with that variable)
//returns artists that start with that letter or number
select name from artist where name like "a%" order by name;
//returns albums that start with that letter or number
select name from album where name like "a%" order by name
//returns songs that start with that letter or number
select title from song where title like "a%" order by title;
//when passed a string (replace a with that variable)
//returns artists that include that string
select name from artist where name like "%a%" order by name;
//returns albums that include that string
select name from album where name like "%a%" order by name;
//returns songs that include that string
select title from song where title like "%a%" order by title;
//returns all albums sorted by album title
select name from album order by name;
//returns all artists sorted by name
select name from artist order by name;
//returns all songs sorted by title
select title from song order by title;
//given an artist id, returns albums by that artist (replace 110 with ID)
select name from album where artistID = 110 order by name;
//given an album id, returns songs in that album (replace 110 with ID)
select title, trackNum from song where albumID = 110 order by trackNum;
//given a song id, return the song (replace 1012 with ID)
select title from song where id = 1012;
//given a song id, insert song into playlist(this one is convoluted but works!)
//just replace 1012 with whatever id the song has
//I figure that this method can be used in conjunction with a loop or iterator or whatever to add an //entire album
insert into Playlist values((select title from song where id = 1012), (select name from artist where artist.id = (select artistID from song where id = 1012)), (select name from album where album.id = (select albumID from song where id = 1012)), (select type from genre where genre.id = (select genreID from song where id = 1012)));
//this is what I have come up with so far. if there are any glaring errors, any suggestions, or anything //that anybody would like to add, feel free to edit or email me!