MYSQL 插入多条数据
selectMedicineIDfromt_medicinewhereMedicineTypeID=887;insertintot_medicinerate(Medici...
select MedicineID from t_medicine where MedicineTypeID=887 ;
insert into t_medicinerate (MedicineID , UnitID , Rate , MaxLimit , Note , OperateID ,OperateTime )
values (MedicineID, 1902 , 1000 ,0, ' ',0,now() );
如何把values (ID, 1902 , 1000 ,0, ' ',0,now() );
里面的ID换成是insert into t_medicinerate (MedicineID , UnitID , Rate , MaxLimit , Note , OperateID ,OperateTime )
所返回的数据,以便出入多条的数据
select MedicineID from t_medicine where MedicineTypeID=887 ;
insert into t_medicinerate (MedicineID , UnitID , Rate , MaxLimit , Note , OperateID ,OperateTime )
values (MedicineID, 1902 , 1000 ,0, ' ',0,now() );
如何把values (ID, 1902 , 1000 ,0, ' ',0,now() );
里面的ID换成是select MedicineID from t_medicine where MedicineTypeID=887 ;
所返回的数据,以便出入多条的数据 展开
insert into t_medicinerate (MedicineID , UnitID , Rate , MaxLimit , Note , OperateID ,OperateTime )
values (MedicineID, 1902 , 1000 ,0, ' ',0,now() );
如何把values (ID, 1902 , 1000 ,0, ' ',0,now() );
里面的ID换成是insert into t_medicinerate (MedicineID , UnitID , Rate , MaxLimit , Note , OperateID ,OperateTime )
所返回的数据,以便出入多条的数据
select MedicineID from t_medicine where MedicineTypeID=887 ;
insert into t_medicinerate (MedicineID , UnitID , Rate , MaxLimit , Note , OperateID ,OperateTime )
values (MedicineID, 1902 , 1000 ,0, ' ',0,now() );
如何把values (ID, 1902 , 1000 ,0, ' ',0,now() );
里面的ID换成是select MedicineID from t_medicine where MedicineTypeID=887 ;
所返回的数据,以便出入多条的数据 展开
3个回答
展开全部
你好,单单的mysql语句没法完成这样复杂的操作,不过你可以写个简单的php页面执行:
前提先连上数据库,
$conn=mysql_connect("localhost","root","")or die("error");
$sql="select MedicineID from t_medicine where MedicineTypeID=887";
$rs=mysql_query($sql,$conn);
while($row = mysql_fetch_array($rs)){
$sql1="insert into t_medicinerate (MedicineID , UnitID , Rate , MaxLimit , Note , OperateID ,OperateTime )
values ('$row[MedicineID]', 1902 , 1000 ,0, ' ',0,now() )";
mysql_query($sql1,$conn);
}
前提先连上数据库,
$conn=mysql_connect("localhost","root","")or die("error");
$sql="select MedicineID from t_medicine where MedicineTypeID=887";
$rs=mysql_query($sql,$conn);
while($row = mysql_fetch_array($rs)){
$sql1="insert into t_medicinerate (MedicineID , UnitID , Rate , MaxLimit , Note , OperateID ,OperateTime )
values ('$row[MedicineID]', 1902 , 1000 ,0, ' ',0,now() )";
mysql_query($sql1,$conn);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Mysql考虑到了您说的这种情况,用insert ... select语句可以实现:
INSERT INTO t_medicinerate (MedicineID , UnitID , Rate , MaxLimit , Note , OperateID ,OperateTime )
select t_medicine.MedicineID, "1902" , 1000 ,0," ",0,now() from t_medicine where t_medicine.MedicineTypeID=887 ;
INSERT INTO t_medicinerate (MedicineID , UnitID , Rate , MaxLimit , Note , OperateID ,OperateTime )
select t_medicine.MedicineID, "1902" , 1000 ,0," ",0,now() from t_medicine where t_medicine.MedicineTypeID=887 ;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
不能
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询