douqiang5163 2013-05-27 13:42
浏览 53

PHP在同一个表中选择不同行的不同值

I have a database with two columns:

1. city : amsterdam, rome, london, amsterdam, rome, new york, ...
2. type : red, green, blue, red, green, ...

I have to select from a database the distinct value of columns and put it together.

The result must be like this:

amsterdam red, amsterdam blue, amsterdam green, rome red, rome blue, rome green, london ...

I tried with "select distinct" and with "array_unique", probably in the wrong way, but I can not get the result.

  • 写回答

2条回答 默认 最新

  • douwa6220 2013-05-27 13:44
    关注
    SELECT DISTINCT city, type
    FROM table
    
    评论

报告相同问题?