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
  • 4,157
  • 2
  • 46
  • 87
  • 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,152
  • 3
  • 28
  • 41
Kai
  • 3,803
  • 1
  • 16
  • 33