php创建表格代码,php 代码创建表格以及CRUD

create table

(

[not null],

,

...

)

primary key 主键

not null 非空

foreign key(Nation) references Nation(Code) 外键

auto_increment 自增长

注意:所有符号必须是英文状态下的

每个表创建完之后加分号

表里面的最后一列写完之后不要加逗号

删除表:

drop table PinPai

增,删,改,查 CRUD

添加:

insert into [(列1,列2....)] values([,‘值2‘])

注意:

1.列与值要匹配(数量,类型,次序)

2.列可以省掉,但值必须与表中的总列数和列的次序完全对应。

3.自增长列,不能省掉自增列,给自增列赋个‘‘

delete from car where code=‘c001‘

delete from car where brand=‘b001‘ or brand=‘b004‘

delete from car where brand=‘b001‘ || brand=‘b004‘

delete from car where brand=‘b007‘ && price>50

delete from car where brand=‘b007‘ and price>50

<> !=

更新

update set [,列=值...] where .....

update info set sex=‘1‘ where code=‘p003‘

update info set sex=‘0‘,nation=‘n004‘,birthday=‘1999-9-9‘ where code=‘p001‘

update car set price=price * 0.9 where price > 30

update car set price =price * 0.95 where (brand=‘b006‘ || brand=‘b005‘)&&price>30

查询

select * from 表名

select 列名1,列名2... from 表名--投影

select * from 表名 where 条件--筛选

1.等值与不等值

select * from car where code=‘c001‘;

select * from car where code != ‘c001‘;

select * from car where price > 30;

--下面的都是范围

select * from car where price >=30 && price <=50;

select * from car where price between 30 and 50

select * from car where brand=‘b002‘ || brand=‘b004‘ || brand=‘b006‘

select * from car where brand in (‘b002‘,‘b004‘,‘b006‘)

2.模糊查

select * from car where name like ‘宝马%‘%--任意多个任意字符

select * from car where name like ‘%5%‘

select * from car where name like ‘%型‘

select * from car where name like ‘__5%‘_ -- 一个任意字符

3.排序

select * from 表名 where .... order by 列名 [ASC/DESC],列名[asc/desc]....

select * from car order by price desc

select * from car order by brand desc,price asc

原文:http://www.cnblogs.com/bilibiliganbei/p/5528145.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值