Reputation: 33
I'm trying to make a query, something like this: SELECT * FROM table WHERE field_name LIKE "keyword%" AND CHAR_LENGTH("keyword%")<20
. I know this one is wrong and it's not working, but what's the right way to get the right results?
Thank you!
Upvotes: 3
Views: 5492
Reputation: 20572
CHAR_LENGTH should be used with field_name not the like pattern: "keyword%"
SELECT * FROM table WHERE field_name LIKE "keyword%" AND CHAR_LENGTH(field_name)<20
Upvotes: 0
Reputation: 166576
Why not try
SELECT *
FROM table
WHERE field_name LIKE "keyword%"
AND CHAR_LENGTH(field_name)<20
Upvotes: 5