After making the following query:
SELECT CP.code
FROM cart_products AS CP
INNER JOIN products AS P
ON P.code = CP.code
WHERE CP.cartID = 22207
AND (P.stock - CP.quantity) > 0
I got the following error:
# 1690 - BIGINT UNSIGNED value is out of range in ('DB_NAME'. 'p'. 'stock' - 'DB_NAME'. 'cp'. 'quantity') '
The structure of the tables is as follows:
CREATE TABLE 'products' (
'productID' int(10) UNSIGNED NOT NULL,
'code' tinytext COLLATE latin1_general_ci NOT NULL,
'stock' mediumint(8) UNSIGNED NOT NULL DEFAULT '0',
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
CREATE TABLE 'cart_products' (
'cartID' int(10) UNSIGNED NOT NULL,
'code' tinytext COLLATE latin1_general_ci NOT NULL,
'quantity' mediumint(8) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
How can I do the query without getting this error?