Q:

Greater than statement with unwanted char in

I have a table (products) with products and price, like the following:
|id|product|price
|1|bicycle|199.00
|2|car|2999.00
|3|doll|19.00

I want to be able to get all products with a price greater than X. Although I the below code doesn't work (it gets product that isn't between the intervals) and I think I encounter it because the dot in the price
Im using CodeIgniter and my query looks like this:
$this->db->from('products');
$this->db->where('id', $row->product_id);

// If price interval is set
if(!empty($start_price))
{
    $this->db->where('products.price >=', $start_price);
    $this->db->where('products.price <=', $end_price);
}

$query = $this->db->get();

Regular statement would be something like
$price = 150.00
$query = 'SELECT * FROM products WHERE price > ' . $price . '";

How can I have a dot in my table column and still use greater than? Its a lot of lines, so changing all is not possible Im afraid 

A:

if your column price is declared as e.g. FLOAT, DOUBLE or DECIMAL , this should work
SELECT * FROM products WHERE price > $start_price1 and price <  $end_price2 ;

if it is declared as VARCHAR
SELECT * FROM products   
 WHERE CAST(price AS FLOAT)> $start_price1  
 AND CAST(price AS FLOAT) < $end_price2;   

