注册 | 登录
收藏 | 帮助
热门文章
编辑推荐
相关文章  
简单三步走堵死SQLServer注入漏洞
黑客攻破SQL服务器系统的十种方法
透明防火墙架设的完全攻略(brid
linux定时备份mysql数据库
DNS (domain Name System) 系统的
qmail+vpopmail+sqwebmail的安装
qmail Vpopmail And sqwebmail H
qmail Vpopmail And sqwebmail H
qmail Vpopmail And sqwebmail H
qmail Vpopmail And sqwebmail H
您现在的位置: 顶尖设计 >> IT学院 >> 数据库 >> MySQL >> 文章正文
MySQL中文参考手册--8.MySQL教程--8.7 双胞胎项目的查询(实例)
作者:晏子  来源:http://linuxdb.yeah.net  点击:  更新:2006-12-20
简介:

在Analytikerna 和 Lentus,我们为一个大的研究项目工程一直在做系统和现场工作。这个项目是Institute of Environmental Medicine at Karolinska Institutet Stockholm 和 the Section on Clinical Research in Aging and Psychology at the University of Southern California的合作项目。

双胞胎研究的更多信息可在下列链接找到:

http://www.imm.ki.se/TWIN/TWINUKW.HTM

项目的后面部分是用一个用Perl和MySQL编写的web接口来管理。

每天晚上所有会谈的数据被移入一个MySQL数据库。

8.7.1 找出所有非独处的双胞胎

下列查询用来决定谁进入项目的第二部分:

select

        concat(p1.id, p1.tvab) + 0 as tvid,

        concat(p1.christian_name, " ", p1.surname) as Name,

        p1.postal_code as Code,

        p1.city as City,

        pg.abrev as Area,

        if(td.participation = "Aborted", "A", " ") as A,

        p1.dead as dead1,

        l.event as event1,

        td.suspect as tsuspect1,

        id.suspect as isuspect1,

        td.severe as tsevere1,

        id.severe as isevere1,

        p2.dead as dead2,

        l2.event as event2,

        h2.nurse as nurse2,

        h2.doctor as doctor2,

        td2.suspect as tsuspect2,

        id2.suspect as isuspect2,

        td2.severe as tsevere2,

        id2.severe as isevere2,

        l.finish_date

from

        twin_project as tp

        /* For Twin 1 */

        left join twin_data as td on tp.id = td.id and tp.tvab = td.tvab

        left join informant_data as id on tp.id = id.id and tp.tvab = id.tvab

        left join harmony as h on tp.id = h.id and tp.tvab = h.tvab

        left join lentus as l on tp.id = l.id and tp.tvab = l.tvab

        /* For Twin 2 */

        left join twin_data as td2 on p2.id = td2.id and p2.tvab = td2.tvab

        left join informant_data as id2 on p2.id = id2.id and p2.tvab = id2.tvab

        left join harmony as h2 on p2.id = h2.id and p2.tvab = h2.tvab

        left join lentus as l2 on p2.id = l2.id and p2.tvab = l2.tvab,

        person_data as p1,

        person_data as p2,

        postal_groups as pg

where

        /* p1 gets main twin and p2 gets his/her twin. */

        /* ptvab is a field inverted from tvab */

        p1.id = 






  • 上一篇文章:
  • 下一篇文章:
  • 分享此文:该页面添加到 Mister Wong 添加到雅虎Yahoo!收藏 Add to:Del.icio.us Post to Furl Digg this 添加到Google书签 reddit spurl blogmarks 365Key 评论  收藏  分享  打印
     我来说两句
    姓名:       验证码:   
    主页: 
    评分: 1分 2分 3分 4分 5分
    本频道近期热评文章:
      关于我们 | 联系我们 | 站点地图 | 广告投放 | 友情链接 | 在线留言 | 版权申明
    版权所有 © 2004-2007 顶尖设计(bobd.cn)
    未经授权禁止转载,摘编,复制本站内容或建立镜像. 沪ICP备07504942号 
    网络110
    报警服务