MySQL Forums
Forum List  »  Newbie

Re: get numbers only question
Posted by: Rick James
Date: July 20, 2014 09:14AM

If employee_numbers are supposed to be "whole numbers":
ALTER TABLE employees MODIFY employee_number INT UNSIGNED NOT NULL;

But this will be messed up: "1.222".

To also handle 1.222, then leave the table alone, but do

SELECT MAX(0+employee_number) FROM employees WHERE employee_number REGEXP ('[0-9]');
The "0+" converts employee_number into a number, which tricks it into doing a 'numeric' MAX. 1.222 will sort between 1 and 2.

Options: ReplyQuote


Subject
Written By
Posted
July 20, 2014 02:16AM
Re: get numbers only question
July 20, 2014 09:14AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.