Delete query with like option is not working

  • Hi friends ,

    I need to Delete from table with conditions :

    Example of my query!!!

    Delete from TAble A where Input_type like 'COLD%' and Input_type like 'ChartMover%'

    when I try to exceute the above query the result show '0 rows affected'

    where as when I try to check using "selete" actually there are records with "Input_type like 'ChartMover%'"

    But my delete is not working with same column to delete with 2 different likes??

    IS my query incorrect??

    Can anyone suggest

    Thanks in advance!!

  • look at the WHERe statement in your query:

    where Input_type like 'COLD%'

    and Input_type like 'ChartMover%'

    it is impossible a string could START with both 'COLD%

    and 'ChartMover% at the same time.

    it's one OR the other; that's why no rows are affected.

    your SELECT query 's WHERE statement needs to exactly match your Delete to affect the same rows!

    here's what i suspect you want: to delete both types:

    Delete

    --SELECT *

    from TAble A

    where Input_type like 'COLD%'

    OR Input_type like 'ChartMover%'

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Duplicate post, post answers here.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply