Y
yzx_lsyh
Unregistered / Unconfirmed
GUEST, unregistred user!
1、SELECT hisData.*<br>FROM client LEFT OUTER JOIN<br> well ON well.clientId = client.id LEFT OUTER JOIN<br> project ON project.wellId = well.id LEFT OUTER JOIN<br> hisData ON hisData.projectId = hisData.projectId<br>WHERE (client.id = '11943988860459749')<br>2、select region.name,client.name,well.no,well.address as wellAddress,project.id as projectId<br>from region left join client on client.townId = region.id <br> left join well on well.clientId = client.id <br> left join project on project.wellId = well.id<br>说明:<br>1、hisData:历史数据记录表;client:取水用户表;well:水井信息记录表;well.clientId:指向取水用户的外键;client.id:取水用户ID号;project:工程信息表;project.wellId:工程信息表.水井ID号;well.id:水井ID号;hisData.projectId:<br>取水工程ID号。<br>2、region.name:行政区划表.行政区名称;client.name:取水用户表.取水户名称;well.no:水井编号;well.address:水井位置;client.townId:取水用户表.所在区县行政区Id号。<br>3、以上两条SQL语句都是对同一数据库进行操作。<br>我越看越糊涂,麻烦各位兄弟姐妹帮忙解释。先谢了!