简体   繁体   English

MySQL LIKE语句错误#1064

[英]MySQL LIKE statement error #1064

in my query I'm using LIKE statement and this is the query: 在我的查询中,我使用LIKE语句,这是查询:

SELECT * FROM ogloszenia WHERE oferta = "Oferta kupna" and LIKE = "cokolwiek" ORDER BY id DESC Limit 5 offset 0;

And I'm getting error like this: 而且我得到这样的错误:

Something is wrong in your syntax near 'LIKE = "cokolwiek" ORDER BY id DESC Limit 5 offset 0' in line 1

Can you tell me how to fix it or what is an issue of this problem? 您能告诉我如何解决它,或者这个问题是什么问题?

Thank you anyway. 还是要谢谢你。

You should not have an equal sign after the LIKE operator and it should be related to a column LIKE运算符后不应包含等号,并且应与列相关

somecolumn LIKE 'cokolwiek'

For LIKE to make any difference over an equal sign add wildcards % and _ to the string. 为了使LIKE在等号上产生任何差异,请在字符串中添加通配符%_

IE: IE浏览器:

somecolumn LIKE '%cokolwiek%'

Reference: http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html#operator_like 参考: http : //dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html#operator_like

(also changed to single quotes for good practise) (为了方便起见,也更改为单引号)

You need to use single quotes, not double quotes. 您需要使用单引号,而不是双引号。 You also shouldn't have an = near LIKE, and need to specify a column name near LIKE . 您也不应在LIKE附近有= ,并且需要在LIKE附近指定列名。 This would look like: 看起来像:

SELECT * FROM ogloszenia WHERE oferta = 'Oferta kupna' AND columnname LIKE 'cokolwiek' ORDER BY id DESC Limit 5 offset 0;

Like is already operator, you don't need to use = 就像已经是运算符一样,您无需使用=

LIKE `cokolwiek`

To get advantage of LIKE you can use wildcard characters. 要使用LIKE ,可以使用通配符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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