Midwest Dev Chat

MidwestDevChat.com github.com/skidvis/Midwest-Dev-Chat

  • The newest 15 messages in the super-cool #database channel.

  • 04/25 12:58:08 Gloria: You want to eliminate duplicates across keys, then? (Composite duplicates?)

  • 04/25 13:01:51 Gloria: How about this?

    SELECT DISTINCT(id)
    
    FROM orders o1
    INNER JOIN orders o2
    ON o1.shipmentID = o2.shipmentID
    WHERE o1.shopifyCustomerID = o2.shopifyCustomerID
    AND o1.id <> o2.id

  • 04/25 13:36:32 Price: All these JOINs are unnecessary

    SELECT * FROM orders WHERE shipmentID = shopifyCustomerID
    

    But if you want to collect all matching ids together you should be using GROUP BY

  • 04/25 13:40:21 Gloria: He doesn’t need `shipmentID = shopifyCustomerID`, though, he needs sets of rows where `shipmentId = shipmentID` and `shopifyCustomerID = shopifyCustomerID`.

  • 04/25 13:40:37 Price: right, that's why I mentioned GROUP BY

  • 04/25 13:44:46 Gloria: Doesn’t that statement compare the two columns in the same row, like against each other? Rather than against other rows?

  • 04/25 13:45:14 Price: that was meant as a critique of the earlier suggestions, not a solution to the actual problem

  • 04/25 13:45:38 Price: if you need to compare two columns in the same row, you don't need a JOIN for that

  • 04/25 13:46:56 Gloria: Right.

  • 04/25 13:48:22 Gloria: That was silly on my part.

  • 04/25 13:49:33 Price: well multiple people made that suggestion so I thought I'd point it out

  • 04/25 13:51:07 Gloria: “Gotta JOIN something.”

  • 04/25 13:51:53 Margarett: all these answers are right, depending on the problem. stuck_out_tongue_winking_eye

  • 04/25 13:58:06 Maryjane: something something bike shed sweat_smile

  • 04/26 08:59:47 Britney: 42?

  • *Usernames have been changed to protect the innocent.

Check out all the cool channels!

Join the conversation!