我已加入多表并获得此结果
project_id | title|phone | office_phone +++++++++++++++++++++++++++++++++++++++ 3 |a |1 |NULL 4 |b |Null |1 4 |b |2 |Null 5 |c |Null |1 5 |c |Null |2 5 |c |Null |3 5 |c |1 |Null 5 |c |2 |Null
现在我希望按项目ID分组,并将数据合并为null
我想要这样的输出
project_id | title|phone | office_phone +++++++++++++++++++++++++++++++++++++++ 3 |a |1 |NULL 4 |b |2 |1 5 |c |1 |1 5 |c |1 |2 5 |c |1 |3 5 |c |2 |1 5 |c |2 |2 5 |c |2 |3
我该怎么做?
答案 0 :(得分:0)
您需要完全外部自联接,但由于MySql不支持<a href="{% url 'polls:results' choice.question_id choice.choice_test%}">{{ choice.choice_test }}</a>
语法,因此您必须恢复为full outer join
才能获得相同的结果:
union
在sqlfiddle上看到它。