I want to write this query:
SELECT * FROM products
WHERE name LIKE '%?%'
OR description LIKE '%?%'
and execute it through java in spring web application. But here problem is when I use LIKE operator it has to be with literals, but when I write '%?%' java doesn't recognize ? like placeholders for parameters, when I add parameters I get error that there is no parameters in my query.
Also if I write %?% without literals I get syntax error.
You can always use concat():
SELECT *
FROM products
WHERE name LIKE CONCAT('%', ?, '%') OR
description LIKE CONCAT('%', ?, '%');
Or use the application to put the wildcards in the pattern string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With