There are two tables fruits and fruits_seasons in the schema and I wanted to get all the monsoon fruits. While trying so I noticed a weird response.
https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=77d52b2736a04a5adf4ffe80881cd4ab
Monsoon months
select group_concat(fruit_id) from fruits_seasons where monsoon = 1;
group_concat(fruit_id) |
---|
2,8,9,11,13,15 |
The query I used
SELECT
f.name AS name, f.price AS price
FROM
fruits f
where f.id in (select group_concat(fruit_id) from fruits_seasons where monsoon = 1);
My expected result
name | price |
---|---|
lemon | 15.00 |
carrot | 35.00 |
papaya | 18.00 |
custard apple | 15.00 |
mango | 25.00 |
apple | 25.00 |
The result I got
name | price |
---|---|
lemon | 15.00 |
What is the reason am I getting a single row instead of multiple?