1. Welcome! Please take a few seconds to create your free account to post threads, make some friends, remove a few ads while surfing and much more. ClutchFans has been bringing fans together to talk Houston Sports since 1996. Join us!

SQL help again and again ... smh and again

Discussion in 'BBS Hangout' started by Luckyazn, Jun 14, 2012.

Tags:
  1. Jimes

    Jimes Member

    Joined:
    Mar 28, 2006
    Messages:
    868
    Likes Received:
    27
    Yeah I don't think you should use count(*) or else everyone will be deleted; just use 1.

    And there is not enough info to help OP.
     
    1 person likes this.
  2. arkoe

    arkoe (ง'̀-'́)ง

    Joined:
    Dec 13, 2001
    Messages:
    10,384
    Likes Received:
    1,597
    Yep... that's a valid point. The exists statement works on the premise that if the subquery returns any results, the exists statement is considered true. If you try to select count(*) or any other aggregate in the subquery you will always return a result causing the exists statement to return true for all records.
     
  3. EssTooKayTD

    EssTooKayTD Member

    Joined:
    Dec 15, 2005
    Messages:
    3,343
    Likes Received:
    74
    Ya, that's why I said intention. I believe this is what he/she meant.

    DELETE FROM clutchfans_users u
    WHERE u.userid IN
    (SELECT t.userid
    FROM threads t
    WHERE t.title LIKE '%SQL help%'
    );

    I bet the OP is wondering how the convo ended up here? hahaha
     
  4. arkoe

    arkoe (ง'̀-'́)ง

    Joined:
    Dec 13, 2001
    Messages:
    10,384
    Likes Received:
    1,597
    It's most likely due to the fact that the only context he provided was a ;).
     
  5. DudeWah

    DudeWah Member

    Joined:
    Oct 10, 2007
    Messages:
    9,643
    Likes Received:
    3,523
    <br>
    Judging by his threads on the subject I'm not sure he knows what "here" is.
     
    1 person likes this.
  6. Luckyazn

    Luckyazn Member

    Joined:
    Jun 23, 2003
    Messages:
    4,375
    Likes Received:
    68
    lol thanks for the help anyway guys ..

    but the main part of my job is not to write queries.

    Was asked by management to help track "reprints" easier.

    I know there's alot of resources online, and I've been doing that for the past 3 days.

    I've actually completed 5 of the queries, but the hard part now is they want me to incorp. it into 1.

    Is hard for me to post everything, because there is so much tables and I believe over 54k columns in the DB.

    Just to think I was working as a sale associate 2 months ago at Microcenter, and now thrown into the corp. world in downtown. Adjusting to this change of scenery.

    I was just asking around for some "advices" and "leads" while I was researching at work.

    UHD taught us **** on SQL ... it was only a 3 wk lesson, but 95% of my job does not include writing queries. I think I learn more about SQL this past wk than my whole time at school.
     
  7. coolweather

    coolweather Contributing Member

    Joined:
    Jul 20, 2005
    Messages:
    2,087
    Likes Received:
    58
    that would work too.. but that's slow. Exists is the way to go.
     
  8. EssTooKayTD

    EssTooKayTD Member

    Joined:
    Dec 15, 2005
    Messages:
    3,343
    Likes Received:
    74
    Well congratulations on what sounds like a good opportunity for you. If you aren't the SQL guy, wouldn't it make more sense to hit up your in-house DB folks? Either way, good luck man. Downtown is a cool place to work at...for a little while, haha. Your sig reminds me of Kanye's couple of lines in "This Way."

    I don't know what's better, gettin laid or gettin paid.
    I just know when I'm gettin one, the other's gettin away

    @Coolweather: Good point. SQL optimization is obviously not my strong suit, heh.
     

Share This Page