[ 永遠的UNIX::UNIX技術資料的寶庫 ]   GB | BIG5

首頁 > 數據庫 > MySQL > 正文
MySQL中文參考手冊--8.MySQL教程--8.7 雙胞胎項目的查詢(實例)
本文出自: http://linuxdb.yeah.net 譯者:晏子 (2001-07-22 18:24:01)

在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 = 

(http://www.fanqiang.com)

    進入【UNIX論壇

相關文章
MySQL中文參考手冊--8.MySQL教程--8.7 雙胞胎項目的查詢(實例) (2001-07-22 18:24:01)
MySQL中文參考手冊--8.MySQL教程--8.6 以批處理模式使用mysql (2001-07-22 18:23:47)
MySQL中文參考手冊--8.MySQL教程--8.5 獲得數據庫和表的信息 (2001-07-22 18:23:34)
MySQL中文參考手冊--8.MySQL教程--8.4 創造並使用一個數據庫 (2001-07-22 18:22:59)
MySQL中文參考手冊--8.MySQL教程--8.3 常用查詢的例子 (2001-07-22 18:22:34)
MySQL中文參考手冊--8.MySQL教程--8.2 輸入查詢 (2001-07-22 18:22:15)
MySQL中文參考手冊--8.MySQL教程--8.1 連接與斷開服務者 (2001-05-27 10:37:07)
MySQL中文參考手冊---21 怎樣對比MySQL與其他數據庫 (2001-05-14 12:11:51)
MySQL中文參考手冊---20 MySQL客戶工具和API (2001-05-14 12:10:54)
MySQL中文參考手冊---19 用MySQL解決一些常見問題 (2001-05-14 12:09:09)

===更多相關===
 

★  樊強制作 歡迎分享  ★