jap*_*ino 2 sql sql-server sql-server-2012
我只是想用词ROMEO JULIET显示描述,即使它不是按时间顺序排列.
ID DESC
1 This is a sample sentence created by romeo and juliet
2 This is a sample sentence with romeo juliet.
3 romeo and juliet.
4 How to query romeo juliet word.
5 This is not included because there no name here.
Run Code Online (Sandbox Code Playgroud)
在上面的示例中,我想显示id 1到4,因为它包含单词romeo juliet.
我怎么能用LIKE做到这一点?
我试过下面的查询
SELECT DESC FROM TableName WHERE DESC LIKE '%ROMEO JULIET%'
Run Code Online (Sandbox Code Playgroud)
但结果只有id 2,因为id 1,3和4中的名称不是按时间顺序排列的.
提前致谢.
您正在寻找一个搜索ROMEO和JULIET的声明
您可以像这样编写SQL
SELECT... WHERE DESC LIKE '%romeo%' AND DESC LIKE '%juliet%'