例子1: from table2 b where a.id=b.id) 例子2: rebatepolicy表是主表,rebatepolicyitems是从表,从表有主表的主键,现在对于主表一些条件的数据的对应子表要求删除. 如下方式: delete from rebatepolicyitems rs where exists ( from rebatepolicy r where rs.rebateguid=r.rebateguid ' and r.creator='名字' ) delete f…
表中有这样的记录,简单的主子表,现要想通过left join 语句把两表关联起来 select * from tbl_diary_reback a left join tbl_diary_reback_files s on a.id =s.diaryrebackid where diaryid = '-7e0f6876:1400eb06d1f:-7fed' and diaryrebackid = '1a75114e:140136e5d5f:-7ff3' 由于子表是两条不同数据,会出现两条记录.如…
本文继成上一篇通过hive分析nginx日志文章,详情参考下面链接: http://www.cnblogs.com/wcwen1990/p/7066230.html 接着来: 创建业务子表: drop table if exists chavin.nginx_access_log_comm; create table if not exists chavin.nginx_access_log_comm( host STRING, time STRING, request STRING, refe…
[sql]mysql管理手头手册,多对多sql逻辑 国家--城市例子 class Country(models.Model): name = models.CharField(max_length=30) def __str__(self): return self.name class City(models.Model): country = models.ForeignKey(Country, on_delete=models.CASCADE) name = models.CharFiel…
Django的外键使用 from django.db import models # Create your models here. class Category(models.Model): name = models.CharField(max_length=) class Article(models.Model): title = models.CharField(max_length=) content = models.TextField() # 是由Category影响Artic…