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