0

I am super newbe in SQL-mySQL stuff and I want to query these entries that contain a column with a specific value but the value already has quotation marks in it, it literally looks like this, quotation marks are already there: "Museum Voor Land-en Volkenkunde, Rotterdam, Holland" So I tried:

SELECT * FROM this_table WHERE museum_name LIKE "Museum Voor Land-en Volkenkunde, Rotterdam, Holland";

returns Empty set (0.00 sec) which I know for a fact, is not true! then I tried (I tried both with double quotes, with single quotes, nothing works)

select * from this_table where museum_name=" "Museum Voor Land-en Volkenkunde, Rotterdam, Holland" ";

returns: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Museum Voor Land-en Volkenkunde, Rotterdam, Holland" "' at line 1

Please let me know how I can query something specific if it already contains quotation marks.

4

3 回答 3

0

您可以只使用转义字符\或使用单引号'或使用%inLIKE子句。

像这样:

SELECT * FROM this_table WHERE museum_name LIKE "%Museum Voor Land-en Volkenkunde, Rotterdam, Holland%";

或者

SELECT * FROM this_table WHERE museum_name = "\"Museum Voor Land-en Volkenkunde, Rotterdam, Holland\"";

或者

SELECT * FROM this_table WHERE museum_name = '"Museum Voor Land-en Volkenkunde, Rotterdam, Holland"';
于 2016-02-15T10:43:23.943 回答
0

您应该使用 backsalsh 转义字符串 \

喜欢

 SELECT * FROM <tbl> WHERE col1 = "gh\"gh"

或者

 SELECT * FROM <tbl> WHERE col1 = 'gh"gh'

两者都可以,但最好使用第一种方法

于 2016-02-15T10:44:58.550 回答
0

像这样试试

SELECT * FROM this_table WHERE museum_name LIKE '"Museum Voor Land-en Volkenkunde, Rotterdam, Holland"';

或者

SELECT * FROM this_table WHERE museum_name LIKE "\"Museum Voor Land-en Volkenkunde, Rotterdam, Holland\"";

转义引号。

于 2016-02-15T10:41:41.763 回答