我有两张table如下:
users table
==========================
| user_id name age |
|=========================
| 1 pete 20 |
| 2 sam 21 |
| 3 nash 22 |
==========================
hobbies table
=========================
| user_id hobby |
|========================
| 1 football |
| 1 running |
| 1 basketball |
=========================
我想创建一个可以按以下格式返回行的配置单元查询:
{ "user_id":1, "name":"pete", "hobbies":["football", "running", "basketball"] }
1条答案
按热度按时间mwkjh3gx1#
加入表格并使用
collect_list
将每个用户的爱好放入array
.使用
collect_set
以获取唯一值,以防重复。