编写顺:
select..........from.......where...... group...... having ...... order.......
执行顺序:
from ......where........ group ....... having....... select......... order
sql意义:根据cno 分组,求price大于60的cno、平均值。
select cno ,avg(price)
from product group by cno
having avg(price) > 60
一对一 :实际用途多,拆表,把它当成一对一看待。
一对多:在多的一方建立外键。 实际用途:用户和收货地址。
多对多:建立中间表,进行关联。实际用途:用户角色表。