SQL Query Help :can i run multiple delete from query at once ??

Discussion in 'Databases' started by seohyderabad, Aug 15, 2008.

  1. #1
    Hi,

    i want to delete link details from phpld database which contains some words (spam world pills c@sin0 etc )

    at present i am executing these one by one .
    ~~~~~~~~
    delete from `PLD_LINK` where `TITLE` like ‘%word1%’
    delete from `PLD_LINK` where `title` like ‘%word2%’

    delete from `PLD_LINK` where `DESCRIPTION` like ‘%word2%’
    delete from `PLD_LINK` where `DESCRIPTION` like ‘%word3%’

    delete from `PLD_LINK` where `URL` like ‘%word1%’
    delete from `PLD_LINK` where `URL` like ‘%word2%’

    ~~~~~~~~

    instead of doing all these one by one can i run one single query or some shortcut

    can i run multiple delete from query at once ??

    could have done these one by one but i need to do this no 100 + dirs thts y looking for a better solution.
     
    seohyderabad, Aug 15, 2008 IP
    Raj Kumar likes this.
  2. dcr226uk

    dcr226uk Peon

    Messages:
    174
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    yeah, use OR command

    for example

    delete from PLD_LINK
    where (URL like '%word%') or (DESCRIPTION like '%word%')

    or even run from a php/asp page, passing a variable as %word%

    asp might be

    word = request.form("word")

    then run the command, that way you can type a keyword into a textbox, and delete all the entries containing that keyword.
     
    dcr226uk, Aug 15, 2008 IP
  3. seohyderabad

    seohyderabad Peon

    Messages:
    1,190
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks dcr226uk

    well i am noob in sql. i just know some basic phpmyadmin things :)

    i think my query would be something like this
    delete from PLD_LINK where (URL like '%word%') or (DESCRIPTION like '%word%') or (TITLE like '%word%')

    & also what if i have more words will this work (URL like '%word%' , '%word2%')
     
    seohyderabad, Aug 15, 2008 IP
  4. net-split

    net-split Peon

    Messages:
    29
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    nope (URL like '%word%' , '%word2%') will not work.
     
    net-split, Aug 18, 2008 IP