Hi I have a table with one record per person and per item of clothing
so
peter, jumper,blue
peter,trousers,green
sue,dress,green
peter,jumper,red
gordon,jumper,green
I want to write a query to select all people with green jumpers but only if they have no other color jumper
So in the above case it would ONLY select Gordon not greedy old Peter
A solution provided is a sub select or multiple select query
SELECT *
FROM myTable AS t1
WHERE t1.clothing = 'jumper' AND t1.color = 'green'
AND NOT EXISTS(SELECT *
FROM myTable AS t2
WHERE t2.person = t1.person AND t2.clothing = 'jumper'
AND t2.color <> 'green')
Subscribe to:
Post Comments (Atom)
TIPS YOUTUBER PEMULA MENINGKATKAN VIEWER
Oke kali saya akan membahas tentang Tips Youtubers Pemula untuk meningkatkan Viewer dan Popularitas Chanel Youtube Kita. Sebagus apapun vide...
-
If a method can be static, declare it static. Speed improvement is by a factor of 4. echo is faster than print . Use echo's multiple pa...
-
Your web site should be easy to read Your web site should be easy to navigate Your web site should be easy to find Your web page layout and ...
-
Banyak orang menghabiskan tak sedikit uang untuk urusan pembuatan dan desain website, namun kemudian mendapati bahwa mereka hanya memiliki s...
No comments:
Post a Comment