Home > database >  Anyone know why the DISTINCT keyword in MYSQL isnt working here?
Anyone know why the DISTINCT keyword in MYSQL isnt working here?

Time:03-10

1

I understand that they aren't exactly duplicate rows, but how do I specify the DISTINCT command to only check for the first column. Thanks in advance

CodePudding user response:

You need

FROM Employees JOIN Departments 
          ON Employees.dep_id = Departments.dep_id

Without an ON clause a JOIN is a Cartesian join, yielding every possible combination of rows in the two tables.

DISTINCT is not useful for solving this problem.

CodePudding user response:

DISTINCT works on the entire row returned, not a single attribute.

(Frank, William, Sales)

...is distinct from...

(Frank, William, IT)

...even if some of the attributes are the same.

PS- please include quoted code and results instead of a link.

  • Related