Running into the following error in MySQL. I have tried using convert as well with no luck. The customer would like to be able to filter data where a customer ID will be something like: BOB102, REB293, REC203. I will need to pretty much be searching for customer numbers > 200, and so on.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTEGER)) > 0 )' at line 6
SELECT `orders_jobs`.*
FROM (`orders_jobs`)
INNER JOIN `orders_users` ON `orders_jobs`.`customer` = `orders_users`.`id`
WHERE `orders_jobs`.`active` = 1
AND `orders_users`.`active` = 1
AND ( CAST(orders_users.cust_number AS INTEGER)) > 0 )
Now these may not always be 3 string characters long it might be 4 also, ie: BKER2938
NOTE: As Edga mentioned, I needed to use UNSIGNED instead of integer, but because of the characters it is converting all to 0 instead, is there possibly a different method?
Data Examples (for the field cust_number): MTQ32499,BGM31620,RES42935,CAM31717,CRED31672 (note the last one is 4 chars. I believe it will only be 3 or 4 characters long)
I need to return only the customers who have cust_number > 40000