Finding number position in string

With help of xdazz answer, I did some changes and got answer finally… SELECT myWord, LEAST ( if (Locate(‘0’,myWord) >0,Locate(‘0’,myWord),999), if (Locate(‘1’,myWord) >0,Locate(‘1’,myWord),999), if (Locate(‘2’,myWord) >0,Locate(‘2’,myWord),999), if (Locate(‘3’,myWord) >0,Locate(‘3’,myWord),999), if (Locate(‘4’,myWord) >0,Locate(‘4’,myWord),999), if (Locate(‘5’,myWord) >0,Locate(‘5’,myWord),999), if (Locate(‘6’,myWord) >0,Locate(‘6’,myWord),999), if (Locate(‘7’,myWord) >0,Locate(‘7’,myWord),999), if (Locate(‘8’,myWord) >0,Locate(‘8’,myWord),999), if (Locate(‘9’,myWord) >0,Locate(‘9’,myWord),999) ) as myPos FROM myTable; Demo

Using reserved words in column names

You can still use key if you want to. Just wrap it with backtick, CREATE TABLE IF NOT EXISTS users ( `key` INT PRIMARY KEY NOT NULL AUTO_INCREMENT, username VARCHAR(50) NOT NULL, ); but as an advise, refrain from using any reserved keyword to avoid future problems. 🙂 MySQL Reserved Keywords List

MySQL LOAD_FILE() loads null values

I copied my file to the location where MySQL has access to. To know the location I used: select @@secure_file_priv; and it gave me /var/lib/mysql-files/. Nothing else worked: neither turning off apparmor, nor changing ownership and permissions, nor merely granting the file privilege. So I rolled back most of that but the right directory still … Read more