Query Only Works When Using Float Data Type

73 views Asked by At

I have a dropdown list populated by this query:

$sql = "SELECT DISTINCT CAST(MR_ID AS INT) AS MR_ID FROM Stage_Rebate_Index";

Then I had a table that would display values in a table based on the selection of the dropdown. I used this query to do so. Everything worked!

$sql_one = "SELECT CAST(Supp_ID AS INT) AS Supp_ID, CAST(MR_ID AS INT) AS MR_ID FROM Stage_Rebate_Index WHERE MR_ID = '$mr_id'";

However, I had to make some changes and this is the query I need to populate my dropdown.

$sql = "SELECT DISTINCT ID_Name, MR_ID as sort_column FROM Stage_Rebate_Index ORDER BY sort_column";

And this is the query I use to display the values in a table based on the selection of the dropdown. However, now it doesnt work whatsoever. Anytime a selection is made, the only thing displayed is the table headers. I have figued it out in that the ID_Name column is a varchar while all other columns are the Float data type. Is there anyway to get around this so it works for varchar data types?

$sql_one = "
SELECT ID_Name, CAST(Supp_ID as INT) as Supp_ID
FROM Stage_Rebate_Index
WHERE ID_Name = '$mr_id'";
0

There are 0 answers