mysql结果需要我的例子

时间:2015-12-02 16:31:26

标签: mysql

我有餐桌。 我需要首先展示开放式餐厅" &安培;然后关闭餐馆的结果,我搜索的邮政编码是2600.所以fisrt list zipcode 2600&然后打开餐厅,然后打开餐厅的其他邮政编码。然后2600封闭的餐厅,然后关闭餐厅的其他邮政编码。

restid  resname Zipcode status
    1   Res1    2600    Open
    2   Res2    2500    Closed
    3   Res3    3600    Closed
    4   Res4    2600    Open
    5   Res5    2500    Closed
    6   Res6    2600    Open
    7   Res7    3600    Open
    8   Res8    3600    Open
    9   Res9    2500    Closed
    10  Res10   2600    Closed

我需要结果......

restid  resname zipcode status
    1   Res1    2600    Open
    2   Res4    2600    Open
    3   Res6    2600    Open
    4   Res7    3600    Open
    5   Res8    3600    Open
    6   Res2    2500    Closed
    7   Res3    3600    Closed
    8   Res5    2500    Closed
    9   Res9    2500    Closed
    10  Res10   2600    Closed

提前致谢。

3 个答案:

答案 0 :(得分:1)

select restid,resname,zipcode,status from sometable order by statys desc

答案 1 :(得分:0)

您可以尝试以下解决方案: -

SELECT restid,resname,zipcode,status FROM restaurant WHERE zipcode = 2600 ORDER BY status DESC;

它可能对你有帮助。

答案 2 :(得分:0)

尝试此查询以获得所需的输出。

select * from restaurant WHERE zipcode = 2600  order by status desc