[英]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我有多个以“She”开头的记录,例如“shepherd”、“shell”、“shelf”……我想返回带有“she”的记录
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):只选择以“she”开头的那些(还将选择以“shephard”等开头的记录):
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.您也许也可以使用正则表达式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.