【发布时间】:2011-06-28 05:48:30
【问题描述】:
我想从数据库表中查询字符串的完全匹配。
当我把查询写成
select description from tproduct where description like '%diamond%'
它运行并以wild card 查询的形式给出结果。比如我有ringdiamond、diamondmaster等。
但我只想得到“钻石”。
为此,我这样做了:
select description from tproduct where description = 'diamond'
但它给出了一个错误:
错误:“where 子句”中的未知列“钻石”
描述栏包含:
This bracelet is composed of round diamond surrounded by milgrain detailing. Its secure setting prevents it from twisting and ensures it will sit impeccably on her wrist.
This stylish design is the perfect accessory for the day or evening. Akoya cultured pearls are lined up by a string of bezel-set round diamond.
【问题讨论】:
-
你确定不是不小心使用了双引号吗?
-
@John Gibb:是的,我很确定。我只用了单引号
-
如果你想使用
LIKE,只需使用不带通配符的select description from tproduct where description like 'diamond' -
@Balanivash:我也试过了,但没用 :(
-
@Romi:我确信上面的查询与您可能正在运行的查询不同。上面的查询没有任何问题。但正如您的错误消息所说,它将“钻石”作为一列读取,如果您在“钻石”周围使用反引号(`)而不是单引号(')