我做错了什么?是否有一些C#翻译麻烦或什么?
string commandText =
@"SELECT sc.sc_n,
sc.provider_n,
sc.sc_external_id,
sc.sc_external_name
FROM t_supplier_codification sc
WHERE sc.product_articul IS NULL
AND (sc.sc_external_name != "")
AND sc_count >= 1
AND provider_n=19
AND LENGTH(sc.sc_external_name)>=10
AND sc_external_name NOT LIKE '%лента%'
AND sc_external_name NOT LIKE '%камера%'
AND sc_external_name NOT LIKE '%Replica%'
AND sc_external_name NOT LIKE '%ET%'
AND sc_external_name LIKE ''
ORDER BY sc_external_name";
您的SQL语法出错:
查看与您的MySQL服务器版本相对应的手册,以便在“”附近使用正确的语法,并且sc_count> = 1 AND provider_n = 19 AND LENGTH
答案 0 :(得分:2)
您需要使用单引号而不是双引号:
(sc.sc_external_name!='')
双引号终止你的字符串。此外,单引号通常用于SQL中的字符串文字,双引号用于列名(和其他对象)。
答案 1 :(得分:0)
当在开头使用@的逐字字符串时,你必须用双qoute分隔双引号。以下是
@"(sc.sc_external_name!="")"
实际上是字符串
(sc.sc_external_name!=")
要解决此问题,您只需添加两个双引号,例如
@"(sc.sc_external_name!="""")"
或者更简单地使用单引号
@"(sc.sc_external_name!='')"
答案 2 :(得分:0)
您的双引号会将它们更改为单引号
答案 3 :(得分:0)
应删除双引号,试试这个:
string commandText = @"SELECT sc.sc_n,sc.provider_n,sc.sc_external_id,sc.sc_external_name
FROM t_supplier_codification sc
WHERE sc.product_articul IS NULL
AND (sc.sc_external_name!='') AND sc_count >= 1 AND provider_n=19 AND LENGTH(sc.sc_external_name)>=10 AND sc_external_name NOT LIKE '%лента%'
AND sc_external_name NOT LIKE '%камера%' AND sc_external_name NOT LIKE '%Replica%' AND sc_external_name NOT LIKE '%ET%' AND sc_external_name LIKE ''
ORDER BY sc_external_name";