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;
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有