November 17, 2009
MySQL REGEXP: where first letter is numeric
Category: mysql, Tags: mysql, regexp, khadlock at 11:58 am
Get MySQL results where the first letter is numeric:
SELECT * FROM table WHERE (LEFT(columnname,1) REGEXP '[0-9]')
Or get MySQL results where the first letter is alpha:
SELECT * FROM table WHERE (LEFT(columnname,1) REGEXP '[a-z]')
November 15, 2009
Using the IN statement to retrieve multiple results from a subquery
Category: mysql, Tags: mysql, khadlock at 8:20 pm
Use the IN statement to retrieve multiple results from a subquery.
SELECT * FROM table WHERE id IN ( SELECT DISTINCT id FROM table WHERE id=1 )
November 14, 2009
Get MySQL results by first letter
Category: mysql, Tags: mysql, khadlock at 7:20 pm
The following SQL selects all the rows where columnname starts with the letter A, switch the letter or make it a variable and get the results you need.
SELECT * FROM table WHERE columnname LIKE 'A%'
