一 、简单的增删改查: 表名为 room 查:select *from 表 where 字段=要查询的值 增:insert into room values(„要增加的值‟,…
) 改:udate 表 set roomjc=‟DDD‟ where id=1;(改变 room 表中字段 id 为 1 的roomjc 的数据) 删: delete from room where id=‟1‟(删除表中字段 ID 为 1 的那一 行数据) 二、建表 Create table 表名( 主键 ID 自增 字段 字段类型 identity(1,1) not null 主键(primary key) 字段 字段类型 null 外键(foreign key) (还有一 个唯一 约束 unique(col_name)) … …… …
) 向表中插入数据: Insert into 表名 values(‟1‟,‟aa‟) ……… ……
删除数据表: Drop table 表名; 三 、数据的查询 1
查询多少到多少之间的数据(用”between”关键字) Select *from room where id between 1 and 5 (查询 id 为 1 到 5 之间的数据) 2
改变字段名 Select 名称=foodname 类型=foodbjf from room (把表中 room 中的字段名为foodname 改成”名称”,foodbjf 改为”类型”) 3
查询重复的数据(关键字”group by” (分组)) g roup by 列名 having 条件表达式 Select *from room where roombjf in(select roombjf from room group by roombjf having count (roombjf)>1