Query1.SQL.Text := 'insert into B (select username,usertype,:getdate from A)' Query1.parambyName('getdate') := GetDate(); 或者 Query1.SQL.Text := Format('insert into B (select username,usertype,%s from A)',[FormatDateTime('YYYY-MM-DD',GetDate())] )
insert into B(field1,field2,field3) select username,usertype,getdate() from A
insert into B (username,usertype,AddDate) select username,usertype,getdate() from A
不好,insert into values是对具体的每一条记录而言的,不象insert into tablea 可以直接成批插入数据。
那我如果对某一条记录进行就是在insert into values的后面加以限制,加上where 用户名=某个固定的值,那么该怎么实现呢
那还是一样使用insert into tableb select 对应的字段 from tablea where 用户名=某个固定的值 就可以了,如果一定要用insert into values,那么可以设定一系列变量,将所要插入的值放在变量中,然后用 insert into table values(@var1,@var2,...)
是吗,谢谢你的指点,我触发器还没看过,那我先看看,顺便问一下上面的大民兄写的程序 Query1.SQL.Text := Format('insert into B (select username,usertype,%s from A)',[FormatDateTime('YYYY-MM-DD',GetDate())] )中的%s是什么意思,两个format的作用是什么
在关键字 'select' 附近有语法错误。
第 1 行: ')' 附近有语法错误。
Query1.parambyName('getdate') := GetDate();
或者
Query1.SQL.Text := Format('insert into B (select
username,usertype,%s from A)',[FormatDateTime('YYYY-MM-DD',GetDate())] )
select username,usertype,getdate() from A
select username,usertype,getdate() from A
可不可以
select 对应的字段 from tablea where 用户名=某个固定的值
就可以了,如果一定要用insert into values,那么可以设定一系列变量,将所要插入的值放在变量中,然后用
insert into table values(@var1,@var2,...)
Query1.SQL.Text := Format('insert into B (select
username,usertype,%s from A)',[FormatDateTime('YYYY-MM-DD',GetDate())] )中的%s是什么意思,两个format的作用是什么