How choose item name include ‘and’

  • I wanna select items such as structure like "A and B", so I use query

    select table.column_1 from table

    where table.column_1 like "%and%"

    The problem is this query not only returns all the items like "A and B", but also has name Andrea, Anderson, England, etc. How can I kick off all the things I don't need.

  • If the data you want is always separated by the and in this way, just add the spaces either side, which will eliminate any strings containing the letters and.

    SELECTSQ1.SomeStuff

    FROM

    (

    VALUES('Andrea'),

    ('Anderson'),

    ('England'),

    ('A and B'),

    ('B and C')

    ) AS SQ1(SomeStuff)

    WHERESQ1.SomeStuff LIKE '% and %'

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

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