简体   繁体   中英

How to select exact value from sql statement

I have multiple records that start with "She" like "shepherd", "shell", "shelf"... I want to return records that has "she" with

SELECT records FROM MYTABLE WHERE records = 'She'

However this returns all data mentioned above... how can I return just "she' without the rest of the data?

如果您想获取带有“She”的单词的记录,则查询应为:

SELECT records FROM MYTABLE WHERE records LIKE 'She %'

To just select the ones that start with "she" (will also select records that start with "shephard" etc):

  SELECT records FROM MYTABLE WHERE records LIKE 'she%'

The ones that have the word "she" in it:

  SELECT records FROM MYTABLE 
      WHERE records LIKE 'she %' OR 
            records LIKE '% she %' OR 
            records LIKE '% she'

You could perhaps use regular expressions as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM