How do/Can I use LIKE in a MySQL view?
If I create a view like so:
CREATE VIEW test_view AS SELECT * FROM mytable WHERE somevalue LIKE 'test%';
...it looks like this when I come back to edit it (so obviously it doesn't work):
CREATE VIEW test_view AS SELECT * FROM mytable WHERE somevalue LIKE '\0\0\0t\0\0\0e\0\0\0s\0\0\0t\0\0\0%';
What am I doing wrong? LIKE must be allowed in a view, so maybe the string should be escaped in s开发者_StackOverflow社区ome way?
What you’re seeing is obviously UTF-32, so your environment is apparently set up to use that encoding and not ASCII. It is not necessarily a bad thing, but you need to set it up to display the character correctly (instead of the byte values); and also to make sure that the back-end really is using UTF-32 as well.
Other than that, it’s really hard to help if you don’t tell us how you edit and run your commands (where do you “come back” after you’ve typed the SQL command?).
精彩评论