`id` int(10) NOT NULL,
`name` varchar(20) NOT NULL,
`password` varchar(32) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
mysql>select version()+------------------+
| version()|
+------------------+
| 5.1.46-community |
+------------------+
1 row in set (0.00 sec)
俺是5.1的版本,没有number这个数据类型,所以id给你用的是INT型
CREATE TABLE `usersbao'k` (id INT AUTO_INCREMENT
,name VARCHAR(20) NOT NULL
,password VARCHAR(32) NOT NULL
,PRIMARY KEY(id))AUTO_INCREMENT = 1--设置自动增长的起始数值
示例:
INSERTINTOTPersonnelChange(
UserId,
DepId,
SubDepId,
PostionType,
AuthorityId,
ChangeDateS,
InsertDate,
UpdateDate,
SakuseiSyaId
)SELECT
UserId,
DepId,
SubDepId,
PostionType,
AuthorityId,
DATE_FORMAT(EmployDate,'%Y%m%d'),
NOW(),
NOW(),
1
FROM
TUserMstWHERE
`Status`=0
ANDQuitFlg=0
ANDUserId>2
扩展资料
mysql从一张表查数据并插入另一张表
INSERTINTOtable1(table1_field1,table1_field2,...)selecttable2_filed1,table2_field2,...fromtable2wherecondition1andcondition2...
//一张表符合条件的数据插入另一张表对应字段中
insertintoshelve_goods_info(product_id,`name`,image,original_amount,amount,spec_id,spec_str,sync_time,last_updtime)selectDISTINCTproduct_id,`name`,image,original_amount,amount,spec_id,spec_str,sync_time,NOW()fromjingguo_order_goodsgroupbyproduct_idorderbysync_timedesc
//根据一张表的数据修改另一张表的数据
updateshelve_goods_infoass,ttastsets.print_title=t.newname,s.price=t.newprice,original_price=Ceil(t.newprice*10/8)wheres.name=t.orname
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)