本文介紹了使用 SELECT 插入的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
我有一個(gè)使用 SELECT
語句插入的查詢:
I have a query that inserts using a SELECT
statement:
INSERT INTO courses (name, location, gid)
SELECT name, location, gid
FROM courses
WHERE cid = $cid
是否可以只選擇名稱、位置"?用于插入,并將 gid
設(shè)置為查詢中的其他內(nèi)容?
Is it possible to only select "name, location" for the insert, and set gid
to something else in the query?
推薦答案
是的,絕對(duì)可以,但請(qǐng)檢查您的語法.
Yes, absolutely, but check your syntax.
INSERT INTO courses (name, location, gid)
SELECT name, location, 1
FROM courses
WHERE cid = 2
當(dāng)然,您可以在其位置放置一個(gè)與 gid
類型相同的常量,而不僅僅是 1.而且,我只是編造了 cid
值.
You can put a constant of the same type as gid
in its place, not just 1, of course. And, I just made up the cid
value.
這篇關(guān)于使用 SELECT 插入的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!