2017-07-18 128 views
0

我的查詢:SQL查詢錯誤字符串

SELECT * FROM ecoprosys.dataset where name="1'-Hydroxyestragole"; 

我的查詢是不行的,因爲它與我的字符串已經在它的逗號混淆。

+1

試用另一報價逸出,就像這樣:'name =「1」' - Hydroxyestragole「' – casraf

+0

請參閱:https://stackoverflow.com/questions/9596652/how-to-escape-apostrophe-in-MySQL獲取更多幫助 – WJS

回答

0

也許你錯過了使用反斜線'\'做轉義字符的事情。

sql_cmd='SELECT * FROM ecoprosys.dataset where name=\'1\'-Hydroxyestragole\''; 
1

您需要escape the single quote禮物in your string literal。嘗試下面的查詢:

SELECT * FROM ecoprosys.dataset where name='1''-Hydroxyestragole'; 
0

你可以嘗試以下方法:

SELECT * FROM ecoprosys.dataset where name='1''-Hydroxyestragole'; 
SELECT * FROM ecoprosys.dataset where name='1'+char(39)+'-Hydroxyestragole'; 
0

$ SQL = SELECT * FROM ecoprosys.dataset其中name = '1' ' - Hydroxyestragole';

0

單引號用起來

SELECT * FROM ecoprosys.dataset其中name = '1' '加倍逃脫 - Hydroxyestragole';

另外

在SQL中,數值應單引號內被封閉

示例:其中name =「約翰」,而不是NAME =「約翰」