php pdo compare money value when column is varchar

Question
$stmt = $dbh->prepare("SELECT * FROM salary_table WHERE "
. "ISNUMERIC(min_compensation) <= :name AND ISNUMERIC(max_compensation) => :name AND date_deleted IS NULL");
$stmt->bindValue(":name", ISNUMERIC($name), PDO::PARAM_STR);

This is how i tried to compare if salary is between value. But i dont get the expected out put. I even got error.

How to compare if values is with in range in php pdo

UPDATE

$name = floatval($_POST['name']);    
$stmt = $dbh->prepare("SELECT * FROM af_hris_masterfile_sss_table WHERE "
. "CAST(min_compensation AS float) <= :name AND CAST(max_compensation AS float) => :name AND date_deleted IS NULL");
$stmt->bindValue(":name", $name, PDO::PARAM_STR);

Getting :

MySQL server version for the right syntax to use near 'float) <= '1000' AND CAST(max_compensation AS float) => '1000' AND date_deleted ' at line 1'

UPDATE

Tried this getting same error:

CONVERT(float,REPLACE(min_compensation,',','.')) <= :name AND CONVERT(float,REPLACE(max_compensation,',','.')) => :name

Show source
| pdo   | php   | mysql   | data-type-conversion   2017-01-06 07:01 0 Answers

Answers ( 0 )

◀ Go back