請原諒我制定合適標題的能力。SQL選擇爲表中的每列返回2行一列
我與列的表:
+-------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+-------+
| name | char(20) | YES | | NULL | |
| pri | int(11) | YES | | NULL | |
| sec | int(11) | YES | | NULL | |
+-------+----------+------+-----+---------+-------+
與數據,如
+--------+------+------+
| name | pri | sec |
+--------+------+------+
| first | 1 | 2 |
| second | 3 | 4 |
| third | 5 | 6 |
+--------+------+------+
我想一個選擇,這將使結果:
+--------+------+
| name | addr |
+--------+------+
| first | 1 |
| first | 2 |
| second | 3 |
| second | 4 |
| third | 5 |
| third | 6 |
+--------+------+
任何幫助不勝感激。
請問你'sec'-'pri' ** **總是等於1? –