Ask for sql sentence?

the Buy, attribute of the data table is the product product, department department, time time, so how to write the sql statement "products purchased by the sales department in 2014 but not purchased by other departments", I have been thinking about it for a long time, but I really can"t figure it out.

Mar.05,2021

SELECT * FROM Buy WHERE id not in (SELECT id where department! = 'sell' and? > time >?) Where? > time >? And department = 'sell';


select distinct product from buy where department = 'sales Department' and left (convert (varchar (10), time,120), 4) = '2014' and
not exists (select distinct product from where department! =' sales Department 'and left (convert (varchar (10), time,120), 4) =' 2014')
this is the writing of sql server. I'm not sure if mysql is the same syntax, if the above functions are used differently. Baidu can do it in one fell swoop


--departmentintdepartment=5
SELECT DISTINCT product FROM [Buy] 

WHERE department=5 AND time=2018 AND Title NOT IN
                                                (
                                                   SELECT DISTINCT product FROM [Buy] WHERE department<>5 AND time=2018
                                                )
--
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31bdf-3416a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31bdf-3416a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?