MySQL Select Where First Character Is

mysql, select

Solution

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

For example:

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

will return 1 for the fields that start with 'a' and 0 for all other values

Problem

How do I select the first character of a cell and use that to define what is returned?

Original source

Related problems