I am trying to use SELECT in SELECT in SQL query, to count the matches, but I am getting SQL error:
Illegal parameter data types INT and row for operation '='
What is incorrect ? How can I fix it ?
Hi,
Error notification Illegal parameter data types INT and row for operation '=', is related to the data type of column included in the condition. The problem can occur because of many reasons.
In this example SELECT in SELECT is used correctly to get the value. Column item_category has data type INT, so in the condition, it expects one INTEGER value:
SELECT item_name FROM items WHERE item_category = (SELECT category_id FROM top_categories WHERE top_category_id = 10);
An error notification will appear for example, when there are multiple columns in the second SELECT:
SELECT item_name FROM items WHERE item_category = (SELECT * FROM top_categories WHERE top_category_id = 10);
In this example SELECT in SELECT is used correctly to count the matches. Column pcs_available has data type INT:
SELECT item_name FROM items WHERE pcs_available <= (SELECT COUNT(id_voucher) FROM vouchers WHERE voucher_type = 15);
You will get error notification also when there are multiple columns in the second SELECT:
SELECT item_name FROM items WHERE pcs_available <= (SELECT COUNT(id_voucher), 125, voucher_activation FROM vouchers WHERE voucher_type = 15);