MySQL Choose where the first character

How to select the first character of a cell and use it to determine what is returned?

+4
source share
2 answers

Take a look at MySQL "String" and "Control Flow" Functions .

For instance:

SELECT IF( LEFT( myField, 1) = 'a', 1, 0) FROM myTable; 

will return 1 for fields starting with 'a' and 0 for all other values

+14
source
+1
source

All Articles