LIKE (MySQL): verschil tussen versies
Naar navigatie springen
Naar zoeken springen
(3 tussenliggende versies door dezelfde gebruiker niet weergegeven) | |||
Regel 3: | Regel 3: | ||
SELECT * FROM pet WHERE name LIKE 'b%'; | SELECT * FROM pet WHERE name LIKE 'b%'; | ||
− | == | + | == Escaping == |
− | + | See case 2022.08 below + https://stackoverflow.com/questions/7343658/like-in-mysql-with-special-character → Learn to love backslashes, it seems. | |
+ | |||
+ | == Case: Problem with non-ASCII characters? (2022.08) == | ||
+ | |||
+ | This doesn't seem to work: | ||
<pre> | <pre> | ||
Regel 16: | Regel 20: | ||
</pre> | </pre> | ||
− | + | * 'é' seems to be a double-byte character. I forgot now what it was | |
+ | * When I update a field through MySQL Workbench, it formed tan SQL statement containing 'é', rather than escaping it somehow | ||
+ | |||
+ | Quick-and-dirty hack: Replace "é" with "e" before doing more advanced stuff that involves LIKE. | ||
+ | |||
+ | == See also == | ||
+ | |||
+ | * [[String delimiters (MySQL)]] | ||
== Bronnen == | == Bronnen == | ||
* http://dev.mysql.com/doc/refman/5.7/en/pattern-matching.html | * http://dev.mysql.com/doc/refman/5.7/en/pattern-matching.html | ||
− | + | * https://stackoverflow.com/questions/7343658/like-in-mysql-with-special-character | |
+ | * https://stackoverflow.com/questions/881194/how-do-i-escape-special-characters-in-mysql |
Huidige versie van 27 aug 2022 om 13:50
Het sleutelwoord like
biedt beperke mogelijkheden voor patroonherkenning in select queries. Bv.:
SELECT * FROM pet WHERE name LIKE 'b%';
Escaping
See case 2022.08 below + https://stackoverflow.com/questions/7343658/like-in-mysql-with-special-character → Learn to love backslashes, it seems.
Case: Problem with non-ASCII characters? (2022.08)
This doesn't seem to work:
select * from wp_term_taxonomy where description like "%é%";
- 'é' seems to be a double-byte character. I forgot now what it was
- When I update a field through MySQL Workbench, it formed tan SQL statement containing 'é', rather than escaping it somehow
Quick-and-dirty hack: Replace "é" with "e" before doing more advanced stuff that involves LIKE.