How to fix this mysql query
SELECT no, name,
(SELECT chapter, max FROM table2 WHERE name = user.name && max = 10) as sub_array1,
(SELECT chapter, max FROM table2 WHERE name = user.name && max = 20) as sub_array2
FROM user ORDER by exp DESC
example expected out result: I want the data to be:
data->name data->no
data->sub_array1->chapter
data->sub_array1->max
data->sub_array2->chapter
data->sub_array2->max
hopefully you can understand this.. please help me
the current query returns: Operand should contain 1 column(s)
basically i want to create something like this
------------------------------------------------------------------------------
no | name | sub_array1
------------------------------------------------------------------------------
1 |myname | sub_array1[0][chapter]=chapter_1, sub_array1[0][max]=100
| | sub_array1[1][chapter]=chapter_2, sub_array1[1][max]=70
| | ...
------------------------------------------------------------------------------
2 |myname_2 | sub_array1[0][chapter]=chapter_1, sub_array1[0][max]=100
| | sub_array1[1][chapter]=chapter_2, sub_array1[1][max]=50
| | sub_array1[2][chapter]=chapter_3, sub_array1[2][max]=60
Thank You,