I have a file of comma-separated user ids. And I'd like to SELECT for these users.
That's to say I imagine it ought to be looking like this:
mysql> SELECT u.token, u.user_id FROM users u WHERE u.user_id IN (SELECT * LOAD_FILE('/home/alex/lzmigration/users'));
Somehow this LOAD_FILE thingy does not work. I'm not sure I understand why.
I'm getting this error:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LOAD_FILE('/home/alex/lzmigration/users'))' at line 1
Here is the version info.
mysql> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 8.0.35-27 |
+-----------+
LOAD_FILE()returns null see: 1; 2 3, ....SELECT LOAD_FILE('/var/lib/mysql-files/users.txt'), now it returns the contents of the file but the comma is now encoded asC. And of course the initially intended query does not work. Is there a way to fix the encoding? The mysql docs does not seem to be verbose on this func.but the comma is now encoded as Csorry, no clue what you do mean. If values are correct, you can useLOAD DATA(and notLOAD_FILE()to import data into an existing table. see: dev.mysql.com/doc/refman/8.0/en/load-data.html. Downside it that you need to create a table first.