+ 1

sql

Tplease help me with the 3rd query of the given link: To finish creating the 'Pop' playlist, add another query that will select the title of all the songs from the 'Pop' artists. It should use IN on a nested subquery that's based on your previous query. https://www.khanacademy.org/computing/computer-programming/sql/more-advanced-sql-queries/p/challenge-playlist-maker

26th Jul 2018, 11:21 AM
Anand Agrawal
6 Answers
+ 2
Ok you could do something like this. Also ive tested this on the test you supplied via the link and its works. Hope this helps. SELECT title FROM songs WHERE artist in(SELECT name FROM artists WHERE genre = 'Pop')
26th Jul 2018, 1:27 PM
ihateonions
+ 2
So I would approach this by creating an array of the titles that have been retuned from the previous query. So create the array from the titles from the previous query. $titlesArray[] = $titleColumn; Now you can run something like this. $titleData =implode("','",$titlesArray); $query = "select * from TABLE where title IN ('$titleData')"; You will need to rejig this a bit but its the basic layout of how you would use IN. IN is good for checking through an array.
26th Jul 2018, 12:48 PM
ihateonions
+ 1
Not sure I can view the whole thing on mobile. (No scrolling?) Maybe someone with a larger screen will be able to view this, but so far it alerts with errors when trying progress to the second or third step, so maybe there's something about the solution for those two steps that it didn't capture.
26th Jul 2018, 12:42 PM
Janning⭐
Janning⭐ - avatar
+ 1
TO ihateonions : Bro thanks for your help but i want it to be done by simple sql queries not by creating array..
26th Jul 2018, 12:50 PM
Anand Agrawal
+ 1
ihateonions thankyou man.. you'r determined🙏🙏🙏
26th Jul 2018, 7:12 PM
Anand Agrawal
- 1
SQL stands for structured query language types of SQL data definition language data control language data manipulation language transition control language
28th Jul 2018, 5:31 AM
deepak sharma
deepak sharma - avatar