0

The question I have is I have to add another restriction: All the listed items have to be green. So i found the colour of the items are in the table xitem. Where should I add that comment to my current code?

My current code is:

SELECT DISTINCT * 
FROM xsale, xdept 
WHERE xsale.deptname IN 
  (
    SELECT deptname 
    FROM xsale 
    WHERE xsale.deptname=xsale.deptname 
    AND deptfloor <> 1
  )
Tanner
  • 2,232
  • 13
  • 22
  • 1
    Your code, as-is, doesn't make much sense. Can you you share sample data and desired results? – JNevill Nov 15 '19 at 15:51
  • 1
    I would recommend getting out of the habit of using a comma for inner joins, primarily for code clarity. Here's a question that details this: https://stackoverflow.com/questions/20467662/the-difference-between-comma-and-join-in-sql – Tanner Nov 15 '19 at 15:54
  • So now i have selected all the products which are not sold on the first floor. I have to add another restriction namely all items have to be green. And those items can be found in the table xitem – Dragonflame Nov 15 '19 at 16:03
  • Using aliases would make this a million times clearer. Your subquery is pointless here because without aliases you have basically said where 1 = 1. Without table definitions and desired output this question is really not answerable. – Sean Lange Nov 15 '19 at 16:39

0 Answers0