CONCAT_GROUP()的方式

时间:2016-01-06 12:05:27

标签: php mysql

我的查询效果很好,但CONCAT_GROUP()的结果比我想要的还多。

查询:

SELECT GROUP_CONCAT(parent.place_name) AS place_name
    FROM address AS node,
        address AS parent
    WHERE node.lft BETWEEN parent.lft AND parent.rgt
    GROUP BY node.id
    ORDER BY node.lft"

address表:

------------------------------------
id  |   place_name   |  lft | rgt
~-----------------------------------
1   |   A            | 1    | 4
~-----------------------------------
2   |   B            | 2    | 3
~-----------------------------------

place_name的结果将是:

A

A, B

但我需要它:

A

B, A

我尝试使用ORDER,但我未能做到正确。你能帮帮我吗?

1 个答案:

答案 0 :(得分:0)

请参阅this link

中的第3个示例
LayoutInflater inflater = getLayoutInflater();
View dialoglayout = inflater.inflate(R.layout.dialog_layout, (ViewGroup) getCurrentFocus());
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(dialoglayout);
builder.show();