in reply to Re: How many different varieties (color, size, etc) of socks do you have in your sock drawer?
in thread How many different varieties (color, size, etc) of socks do you have in your sock drawer?

That code makes no sense. LIKE without a wildcard means equals, so the two conditions cancel each other out. Unless sock means color, in which case it would at best tell you what you have a set of. But for that, it would be much clearer to write:

SELECT sock FROM socks GROUP BY sock HAVING COUNT(*) > 1 LIMIT 1;

Of course, that completely ignores ids (which sock) and the state of the sock. At the very least, you ought to check for State = 'Washed' or MIN(Times_Worn).

  • Comment on Re^2: How many different varieties (color, size, etc) of socks do you have in your sock drawer?
  • Download Code