Tras realizar la siguiente consulta:
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
Obtuve el siguiente error:
#1690 - BIGINT UNSIGNED value is out of range in (`DB_NAME`.`p`.`stock` - `DB_NAME`.`cp`.`quantity`)'
La estructura de las tablas es la siguiente:
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;
¿Como puedo hacer la consulta sin obtener este error?