切换风格

Wizard Sky California Sunset glow Black Cloud Beige Dragon Lavender NewYear City Snow Flowers London
收藏本站XSS平台字符串转换jsfuck
Django怎么多表联合查询?[复制链接]
发表于 2015-8-11 16:15:57 | 显示全部楼层 |!read_mode!
各位大神都出来帮解决个问题。Django怎么多表联合查询,根据name字段查询两张表的所有数据?
如:
A表:name,pwd,mail 字段
B表:name,pwd,mail 字段


models.py 模型:
class A{
    name = models.CharField(max_length=20)
    pwd = models.CharField(max_length=32)
    mail = models.EmailField()
}
 
 
class B{
    name = models.CharField(max_length=20)
    pwd = models.CharField(max_length=32)
    mail = models.EmailField()
}


发表于 2015-8-12 13:27:24 | 显示全部楼层
不懂,来观摩一下
发表于 2017-3-3 21:22:02 | 显示全部楼层
select b.name,a.pwd from A as a left join b as B on a.name = b.name

代码区

GMT+8, 2019-9-17 05:00

Powered by Discuz! X2

© 2001-2018 Comsenz Inc.

回顶部