本文介紹了如何使用 MySQL SELECT 創(chuàng)建虛擬列?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
如果我做 SELECT a AS b 并且 b 不是表中的列,查詢會(huì)創(chuàng)建虛擬"列嗎?
If I do SELECT a AS b and b is not a column in the table, would query create the "virtual" column?
事實(shí)上,我需要將一些虛擬列合并到查詢中,并將一些信息處理到查詢中,以便我以后可以將其用于每個(gè)項(xiàng)目.
in fact, I need to incorporate some virtual column into the query and process some information into the query so I can use it with each item later on.
推薦答案
類(lèi)似:
SELECT id, email, IF(active = 1, 'enabled', 'disabled') AS account_status FROM users
這允許您進(jìn)行操作并將其顯示為列.
This allows you to make operations and show it as columns.
您還可以使用連接并將操作顯示為列:
you can also use joins and show operations as columns:
SELECT u.id, e.email, IF(c.id IS NULL, 'no selected', c.name) AS country
FROM users u LEFT JOIN countries c ON u.country_id = c.id
這篇關(guān)于如何使用 MySQL SELECT 創(chuàng)建虛擬列?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!