tags:

views:

168

answers:

2

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

+1  A: 

Try reading this article

http://stackoverflow.com/questions/343900/selecting-rows-where-first-n-chars-are-equal-mysql

Also here is an article on mysql regular expressions

http://www.unixcities.com/mysql/manual_regexp.html

Will Ayers
+1  A: 

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

idrosid
Works perfectly thank you :)
Ben Shelock