选择具有特定前缀的项目 [英] SELECT ITEMS with specific prefix

查看:56
本文介绍了选择具有特定前缀的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有一个带有列的数据表(Id,Name,Price,Quantity)



在字段名称我有以下数据:

福克斯森林

福克斯蓝igua

狐狸红雾

..





我想选择所有有狐狸字样的产品

我试过

选择ID,名称,价格,数量

来自产品

WHERE名称类似'Fox'



但是为了正常工作我怎么修改我的查询没有用?





Thnx提前!!

Jason

解决方案

SELECT Id,Name,Price,Quantity

来自产品

WHERE Name LIKE'%Fox%'


  SELECT  Id,Name,价格,数量
来自产品
WHERE 名称 LIKE ' Fox%'


使用 LIKE运算符

在WHERE子句中使用类似运算符来搜索列中的指定模式。



: - 零个或多个字符的替代品

_ : - 替代a单个字符

[charlist] : - 匹配的字符集和范围

[^ charlist]或[!charlist] : - 仅匹配括号内未指定的字符

  SELECT  ID,名称,价格,Quantity  From 产品 WHERE 名称 LIKE  < span class =code-string>' %Fox%' 


Hi guys,

I have a datatable with columns (Id,Name,Price,Quantity)

in field Name I have data like:
Fox forest
Fox blue igua
Fox red mist
..
etc

I want to select all products which the have word fox inside
I tried
SELECT Id,Name,Price,Quantity
From Products
WHERE Name LIKE 'Fox'

but it didn't worked how imust modify my query in order to work properly?


Thnx in advance !!
Jason

解决方案

SELECT Id,Name,Price,Quantity
From Products
WHERE Name LIKE '%Fox%'


SELECT Id,Name,Price,Quantity
From Products
WHERE Name LIKE 'Fox%'


use LIKE operator:
Like Operator is used in a WHERE clause to search for a specified pattern in a column.

% :- A substitute for zero or more characters
_ :- A substitute for a single character
[charlist] :- Sets and ranges of characters to match
[^charlist] or [!charlist] :- Matches only a character NOT specified within the brackets

SELECT ID,Name,Price,Quantity From Products WHERE Name LIKE '%Fox%'


这篇关于选择具有特定前缀的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆