将相同的票价与等级分组

时间:2014-06-05 11:03:35

标签: php arrays

我的选择查询输出如下

[0] => stdClass Object
    (
        [TicketPrice] => 80
        [Grade] => O-1
    )

[1] => stdClass Object
    (
        [TicketPrice] => 80
        [Grade] => O-2
    )

[2] => stdClass Object
    (
        [TicketPrice] => 80
        [Grade] => O-3
    )

[3] => stdClass Object
    (
        [TicketPrice] => 90
        [Grade] => O-4
    )

[4] => stdClass Object
    (
        [TicketPrice] => 70
        [Grade] => O-5
    )

[5] => stdClass Object
    (
        [TicketPrice] => 80
        [Grade] => G-1
    )
[6] => stdClass Object
    (
        [TicketPrice] => 90
        [Grade] => G-2
    )
[7] => stdClass Object
    (
        [TicketPrice] => 90
        [Grade] => G-2
    )

我需要输出就像我提到的

1.O-1到O-3价格是80  2.0-4是90  3.G-2到G-2的价格是90

1 个答案:

答案 0 :(得分:0)

你喜欢这个,

SELECT TicketPrice, Grade FROM table_name WHERE [ conditions ] GROUP BY TicketPrice;