1. You have an
SQL injection vulnerability in your code.
2. The /set command does not accept "=" as an argument. It's either /var %2 = $2 or /set %2 $2. In this case, you actually want /var, because you want a local variable, not a global.
3. You can debug stuff by using /echo to see the full line. If you did this, you would see that the SQL you were attempting to execute was:
SELECT id, datum, text FROM loonakia_quotes WHERE id = = 1
Note the 2nd "=" sign.
In general, when things don't work, you should visualize the data that you are working with. In this case, it means running /echo -a %sql in your script to see what the actual query was. That way you don't have to come here every time something doesn't work as intended.
But most importantly, you have an SQL injection vulnerability in your code. I realize I'm repeating the 1st point, but it's worth repeating. Someone could probably delete your entire database under the right conditions.
As a sidenote, I'm willing to bet that MySQL is a huge overkill for your current project. You can avoid SQL injection vulnerabilities and complexities like screwing up SQL statements by avoiding it entirely. The equivalent quotes script is literally a one liner without SQL:
on *:text:!quote *:#:msg # $read(quotes.txt,$2)
25 lines down to 1. No SQL injection. Way easier to understand, way harder to break, doesn't require running a MySQL server, and given the way the other script is written, this is still probably faster, too. You could make your script even faster by formatting your quotes in a .ini file and /hload'ing them into an in memory hash table, at which point performance will
almost always be faster than MySQL, but this is probably not necessary given that you'd need more than 20k lines of quote data to actually make this a significant processing burden on mIRC.