0

I use MySql, when running below query, I find it acts differently in two box, could any one help me out?

The code is here:

SELECT *
FROM `product` AS `e`
WHERE e.id NOT IN((SELECT `product_id` FROM `sales`))

In one box, it works well and returns the result. In the other box, it shows the error: [Err] 1242 - Subquery returns more than 1 row

And it works well in both box if remove one pair of (), as below:

SELECT *
FROM `product` AS `e`
WHERE e.id NOT IN(SELECT `product_id` FROM `sales`)

Could anyone tell me the reason, i.e. related to server setting? Can I fix this without modify the sql statements?

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
SICON
  • 65
  • 1
  • 10

1 Answers1

0

The data;

 (SELECT `product_id` FROM `sales`)

is treated as the first item in the list to be used by 'NOT IN'. This must be a single value, so you get the error because multiple rows are returned.

splash21
  • 799
  • 4
  • 10