首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >mysql中创建表实例全析及查询基本操作

mysql中创建表实例全析及查询基本操作

作者头像
闵开慧
发布于 2018-03-30 14:18:16
发布于 2018-03-30 14:18:16
2.1K0
举报
文章被收录于专栏:闵开慧闵开慧
代码语言:javascript
复制
 create table cats(  
 id int not null auto_increment,  
 pid int not null default '0',  
 name varchar(60) not null default '',  
 desn text not null default '',  
 primary key(id),  
 index name(name, pid)  
 
 )engine=InnoDB default character set=utf8; 
 create table products(
 id int not null auto_increment,
 cid int not null default '0',
 name varchar(60) not null default '',
 price double not null default '0.00',
 num int not null default '0',
 desn text,
 ptime int not null default '0',
 primary key(id),
 key pname(name, price)
 )engine=InnoDB default character set=utf8; 
 mysql> select a.id aid, b.id bid, a.name aname, b.name bname from products a, products b; 
 mysql> select a.id aid, b.id bid, a.name aname, b.name bname from products a, products b where a.id=b.cid; 
 mysql> select a.id aid, b.id bid, a.name aname, b.name bname from products a, products b where a.id=b.cid order by aid; 
 mysql> select a.id aid, b.id bid, a.name aname, b.name bname from products a, products b where a.id=b.cid order by aid desc; 
 mysql> select a.id aid, b.id bid, a.name aname, b.name bname from products a, products b where a.id=b.cid order by aid asc 
 mysql> select a.id aid, b.id bid, a.name aname, b.name bname from products a, products b where a.id=b.cid order by aid asc limit 5; 
 mysql> select * from products group by cid having cid between 2 and 9; 
 mysql> select * from products group by cid having cid between 2 and 9 order by name limit 4; 
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档