0

A colum in my databse table has alphanumeric values. I want to get only the rows, having numeric values in this column.

$this->Mymodel->find('all', 
    'condition' => array('Mymodel.field') => ???)
);
Simon
  • 3,563
  • 1
  • 41
  • 75
  • Please always mention your exact CakePHP version, and when it's about queries don't forget the DBMS/Schema details. http://stackoverflow.com/q/5064977 | http://stackoverflow.com/q/338075 | http://stackoverflow.com/q/16195986 etc... – ndm Apr 23 '14 at 21:30

1 Answers1

3

If you're using MySQL, you could use Regular Expressions.

$this->Mymodel->find('all', 'conditions' => array('Mymodel.field REGEXP "^[0-9]+$"'));
Rajeev Ranjan
  • 4,163
  • 2
  • 27
  • 40
Kai
  • 3,743
  • 1
  • 14
  • 32