0
我在写一个查询从这样一个表中获取数据的挣扎:SQL - 转换多对多的桥接表,以一对一表
id food_id ingre_id
1 1 13
2 1 9
3 2 13
4 3 5
5 4 9
6 4 10
7 5 5
假设在该表中,每个food
只有1或2英寸ID。然后我想要这样的表格:
item_id ingre1_id ingre2_id
1 13 9
2 13 null //any food that have 1 ingre then set ingre2_id to null
3 5 null
4 9 10
5 5 null
请给我一个查询来做这种转换。谢谢!
@SloanThrasher。 。 。你知道'case'是什么吗?这相当有意不*这样做。 –