Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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

by Dallaylaen (Chaplain)
on Oct 06, 2016 at 16:33 UTC ( #1173419=note: print w/replies, xml ) Need Help??


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

SELECT l.sock, r.sock FROM socks r, socks l WHERE l.sock LIKE r.sock and l.sock <> r.sock LIMIT 1;
  • Comment on Re: How many different varieties (color, size, etc) of socks do you have in your sock drawer?
  • Download Code

Replies are listed 'Best First'.
Re^2: How many different varieties (color, size, etc) of socks do you have in your sock drawer?
by chacham (Prior) on Oct 07, 2016 at 20:49 UTC

    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).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1173419]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2020-03-29 22:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    To "Disagree to disagree" means to:









    Results (171 votes). Check out past polls.

    Notices?