簡體   English   中英

Mysql,“插入”

[英]Mysql, "insert into“

我想寫一條類似的SQL語句

  insert into mytable column1=value1
 and 
((column2,column3,column4) 
(select filed1, filed2,filed3 
from anothertable where filed4=a_varible))

我正在使用Mysql。 上面的陳述僅表達了我要實現的目標。 可能嗎? 有沒有辦法做到這一點?

您可能想要這樣的東西:

Insert Into mytable(column1,column2,column3,column4)
Select 'value1',filed1, filed2,filed3 from anothertable where filed4=a_varible

您可以在select子句中包含一個硬編碼值,它將選擇該值作為每一行的常量。

您可以使用INSERT INTO來做到這一點,例如:

insert into mytable
(column1, column2, column3, column4)
select 'value1', filed1, filed2, filed3 
from anothertable 
where filed4 = 'some value'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM