+ 3

Why wont this code return results for the second query?

I am a beginner with SQL and have been going through various SQL challenges online. Im currently working on: https://www.testdome.com/questions/sql/pets/12347?type=FromTest&generatorId=12&questionIds=13651%2c14246%2c12347 I have tried various methods, but what I believed to be the best isn't working. I did: select distinct name from dogs; select distinct name from cats where name != (select name from dogs); But it will not return any cat names, any thoughts?

16th Jan 2019, 1:59 PM
Kevin Hoelck
Kevin Hoelck - avatar
3 Réponses
+ 6
you were close. select distinct name from dogs union select distinct name from cats; try this one.
16th Jan 2019, 2:21 PM
notqueued
notqueued - avatar
+ 4
you're welcome. hey, you can do it without distinct, because union by itself will remove the duplicate rows
16th Jan 2019, 2:44 PM
notqueued
notqueued - avatar
+ 1
Looks like I was overthinking it, lol. Thank you!
16th Jan 2019, 2:33 PM
Kevin Hoelck
Kevin Hoelck - avatar