1.多表连接查询:当我知道这点的时候顿时觉得django太NX了. class A(models.Model): name = models.CharField(u'名称') class B(models.Model): aa = models.ForeignKey(A) B.objects.filter(aa__name__contains='searchtitle') 1.5 我叫它反向查询,后来插入记录1.5,当我知道的时候瞬间就觉得django太太太NX了.
概要 本节要实现的是多表关联查询的简单demo.场景是根据id查询某商品分类信息,并展示该分类下的商品列表. 一.Mysql测试数据 新建表Category(商品分类)和Product(商品),并插入几条测试数据. create table Category ( Id int not null auto_increment, Name ) null, constraint pk_category primary key (Id) ); INSERT INTO category(Name) VAL
一.多表关联查询 1,left join RelaTimeLog表 和 ValidFlight表关联查询 order by t.FlightId desc 2,与group by连用 group by FlightId) order by t.FlightId desc 二.分页 1,查询0到10条 and order by t.Etd desc 2,BETWEEN * AND * , Row_Number() OVER(ORDER BY *) AS rowNum group by Fli