I need to find valid records as part of a database cleanup script.

What I need is a regular expression that will match, for a single column:

records containing BOTH numbers AND letters (or any other character).
records containing ONLY numbers (including decimals)

Invalid records are those which contain ONLY letters and I do not want these returned, or NULL for the column.

Anybody good with regex?

Solved as follows:

SELECT model FROM products WHERE model != '' AND model != '0' AND (model REGEXP '[0-9][a-z]' OR model REGEXP '[0-9]')

commented: Thanks for sharing. +13
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.