I'm trying to export the DB records from the table via "SELECT INTO OUTFILE". Everything works. But I need to filter the records and this is the problem. Here's the code:
SELECT * INTO OUTFILE 'file.txt' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'
FROM table_name WHERE name LIKE '%John%' AND LENGTH(name) <= 10 ORDER BY name
This statement doesn't work, but if I remove the "name LIKE '%John%'" condition, it works. But I need to specify this LIKE condition, how can I accomplish it?
Thanks.
Could be a problem with the %sign. Try replacing
WHERE name LIKE '%John%'
with
WHERE LOCATE(name, 'John') > 0
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