st.executeUpdate("insert into groupperformance (Date,Gid,GName) values('"+yourDate+"',select Gid,GroupName from grouping)");对于insert表values.In,我使用上面的查询。表变量yourDate具有当前的系统Date.And,我复制表中的数据,grouping.With out yourDate变量查询可以很好地工作,将值从分组表插入到GroupPerformancetable.What,可以作为默认值插入当前日期。
发布于 2014-05-07 09:22:41
st.executeUpdate(
"insert into groupperformance (Date,Gid,GName)
select '" + yourDate + "', Gid,GroupName from grouping"
);但是,请确保yourDate字符串是有效的MySQL日期格式YYYY-MM-DD。
而且,如果要从数据库服务器插入当前日期,则可以使用now()或curdate()代替所选日期。
st.executeUpdate(
"insert into groupperformance (Date,Gid,GName)
select curdate(), Gid,GroupName from grouping"
);发布于 2014-05-07 09:20:18
您可以使用SELECT GETDATE() AS CurrentDateTime,它将返回2008-11-11 12:45:34.243
或者类似的东西:
CREATE TABLE Orders
(
OrderId int NOT NULL PRIMARY KEY,
ProductName varchar(50) NOT NULL,
OrderDate datetime NOT NULL DEFAULT GETDATE()
)发布于 2014-05-07 09:21:25
您可以使用mysql的NOW()函数:
st.executeUpdate("insert into groupperformance (Date,Gid,GName) values(NOW(),select Gid,GroupName from grouping)");https://stackoverflow.com/questions/23513656
复制相似问题