我想知道是否可以爲查詢結果分配臨時/虛擬ID?mysql&php:查詢結果的臨時/虛擬ID?
舉例來說,我有這個作爲我的查詢,
SELECT
pg_id AS ID,
pg_url AS URL,
pg_title AS Title,
pg_content_1 AS Content
FROM root_pages
ORDER BY pg_created DESC
輸出:
ID URL Title Content
53 a A xxx
40 b B xxx
35 c C xxx
可以看到ID之間的差距 - 他們都非常凌亂。我不知道如果我可以做一個虛擬列或東西,所以我有下面的輸出,
ID URL Title Content Virtual ID
53 a A xxx 3
40 b B xxx 2
35 c C xxx 1
這樣從下面的查詢,
SELECT
pg_id AS ID,
pg_url AS URL,
pg_title AS Title,
pg_content_1 AS Content
FROM root_pages
ORDER BY virtual_id DESC
是否有可能?
謝謝!
爲什麼你需要爲虛擬ID仍然存在? – Breezer 2010-10-31 16:47:26
,以便我可以做到這一點 - ORDER BY virtual_id DESC – laukok 2010-10-31 16:51:08
你仍然可以與ID獨自? – Breezer 2010-10-31 16:55:32