<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    2011年11月23日

    (轉(zhuǎn)貼)數(shù)據(jù)庫連接(內(nèi)連接,外連接,交叉連接)

    數(shù)據(jù)庫連接分為:內(nèi)連接,外連接(左、右連接,全連接),交叉連接
    文章地址 : http://www.zxbc.cn/html/20080527/51189.html
    轉(zhuǎn)載 
    內(nèi)連接:把兩個表中數(shù)據(jù)對應(yīng)的數(shù)據(jù)查出來 
    外連接:以某個表為基礎(chǔ)把對應(yīng)數(shù)據(jù)查出來(全連接是以多個表為基礎(chǔ)) 
    student表 
    no name 
    1     a 
    2     b 
    3     c 
    4     d 
    grade表 
    no grade 
    1     90 
    2     98 
    3     95 
    內(nèi)連接 inner join(查找條件中對應(yīng)的數(shù)據(jù),no4沒有數(shù)據(jù)不列出來) 
    語法:select * from student inner join grade on student.no = grade.no 
    結(jié)果 
    student.no name grade.no grade 
    1             a             1         90 
    2             b             2         98 
    3             c             3         95 
    左連接(左表中所有數(shù)據(jù),右表中對應(yīng)數(shù)據(jù)) 
    語法:select * from student left join grade on student.no = grade.no 
    結(jié)果: 
    student.no name grade.no grade 
    1                 a         1         90 
    2                 b         2         98 
    3                 c         3         95 
    4                 d     
    右連接(右表中所有數(shù)據(jù),左表中對應(yīng)數(shù)據(jù)) 
    語法:select * from student right join grade on student.no = grade.no 
    結(jié)果: 
    student.no name grade.no grade 
    1                 a         1         90 
    2                 b         2         98 
    3                 c         3         95 
    全連接 
    語法:select * from student full join grade on student.no = grade.no 
    結(jié)果: 
    no name grade 
    1     a     90 
    2     b     98 
    3     c     95 
    4     d 
    1     a     90 
    2     b     98 
    3     c     95 
    注:access 中不能直接使用full join ,需要使用union all 將左連接和右連接合并后才可以

    交叉連接
    將兩個表所有行組合,連接后的行數(shù)為兩個表行數(shù)的乘積(笛卡爾積)
    語法,借用上面的例子應(yīng)該是
    select * from student cross join grade

    行數(shù)應(yīng)該為12行 :
    no name grade 
    1     a     90 
    2     b     98 
    3     c     95 
    4     d  
    1     a     90 
    2     b     98 
    3     c     95 
    4     d 
    1     a     90 
    2     b     98 
    3     c     95 
    4     d 

    posted @ 2011-11-30 17:24 AK47 閱讀(498) | 評論 (0)編輯 收藏

    JAXB向Xml非根節(jié)點添加一個或多個屬性

    JAXB 向Xml非根節(jié)點添加一個或多個屬性,直接上代碼,關(guān)于JAXB的相關(guān)注解可查閱JAVA API。

    原創(chuàng)文章,轉(zhuǎn)載請注明出處。http://www.tkk7.com/kangdy/archive/2011/11/23/364635.html

    code1: colors類  根節(jié)點
    code1
    package com.kangdy.test;

    import javax.xml.bind.annotation.XmlAccessType;
    import javax.xml.bind.annotation.XmlAccessorType;
    import javax.xml.bind.annotation.XmlElement;
    import javax.xml.bind.annotation.XmlRootElement;

    @XmlRootElement(name = "Colors")
    @XmlAccessorType(XmlAccessType.FIELD)
    public class Colors {
        
        @XmlElement(name = "red",nillable=true)
        private Red red;
        
        @XmlElement(name = "blue",nillable=true)
        private Blue blue;

        public Red getRed() {
            return red;
        }

        public Blue getBlue() {
            return blue;
        }

        public void setRed(Red red) {
            this.red = red;
        }

        public void setBlue(Blue blue) {
            this.blue = blue;
        }
    }

    code2:  Red類  子節(jié)點
    code2package com.kangdy.test;

    import javax.xml.bind.annotation.XmlAccessType;
    import javax.xml.bind.annotation.XmlAccessorType;
    import javax.xml.bind.annotation.XmlAttribute;
    import javax.xml.bind.annotation.XmlRootElement;

    @XmlRootElement(name = "red")
    @XmlAccessorType(XmlAccessType.FIELD)
    public class Red {
        
        private String value;
        
        @XmlAttribute(name = "att1")
        private String att;
        
        public String getValue() {
            return value;
        }
        
        public void setValue(String value) {
            this.value = value;
        }

        public String getAtt() {
            return att;
        }

        public void setAtt(String att) {
            this.att = att;
        }
        
    }


    code3:  類 Blue 子節(jié)點
    code3
    package com.kangdy.test;

    import javax.xml.bind.annotation.XmlAccessType;
    import javax.xml.bind.annotation.XmlAccessorType;
    import javax.xml.bind.annotation.XmlAttribute;
    import javax.xml.bind.annotation.XmlRootElement;

    @XmlRootElement(name = "blue")
    @XmlAccessorType(XmlAccessType.FIELD)
    public class Blue {
        private String value;
        
        @XmlAttribute(name = "att2")
        private String att2;
        
        @XmlAttribute(name = "att1")
        private String att;
        
        public String getAtt() {
            return att;
        }

        public void setAtt(String att) {
            this.att = att;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }

        public String getAtt2() {
            return att2;
        }

        public void setAtt2(String att2) {
            this.att2 = att2;
        }
    }

    code4: main類
    code4
    package com.kangdy.test;

    import java.io.StringWriter;

    import javax.xml.bind.JAXBContext;
    import javax.xml.bind.Marshaller;

    public class Jaxbtest {
        public static void main(String[] args) throws Exception {

            StringWriter writer = new StringWriter();
            JAXBContext jc = JAXBContext.newInstance(Colors.class);
            Marshaller ma = jc.createMarshaller();
            ma.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
            
            Colors colors = new Colors();
            Red red = new Red();
            red.setAtt("att-red");
            red.setValue("red");
            Blue blue = new Blue();
            blue.setValue("blue");
            blue.setAtt("att-blue");
            blue.setAtt2("blue-att2");
            colors.setRed(red);
            colors.setBlue(blue);
            
            ma.marshal(colors, writer);
            System.out.println(writer.toString());

        }
    }

    運行結(jié)果:
    結(jié)果
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Colors>
        <red att1="att-red">
            <value>red</value>
        </red>
        <blue att1="att-blue" att2="blue-att2">
            <value>blue</value>
        </blue>
    </Colors>

    posted @ 2011-11-23 14:33 AK47 閱讀(10146) | 評論 (4)編輯 收藏

    <2011年11月>
    303112345
    6789101112
    13141516171819
    20212223242526
    27282930123
    45678910

    導航

    統(tǒng)計

    常用鏈接

    留言簿

    隨筆分類

    隨筆檔案

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲综合图片小说区热久久| 日本一区二区三区在线视频观看免费 | 久久精品国产99国产精品亚洲| 亚洲午夜日韩高清一区| 成人影片麻豆国产影片免费观看| 97超高清在线观看免费视频| 久久亚洲中文字幕无码| 亚洲中文久久精品无码1 | 久久国产乱子伦精品免费看| 一本久久免费视频| 亚洲精品无码专区| 99久久国产亚洲综合精品| 亚洲精品电影在线| 久久亚洲一区二区| 久久久久亚洲精品中文字幕 | 亚洲AV日韩AV无码污污网站| 亚洲国产情侣一区二区三区| 亚洲AV日韩AV天堂一区二区三区| 国产成人综合亚洲亚洲国产第一页| 四虎影库久免费视频| 我要看免费的毛片| 国产成人免费高清激情视频| xx视频在线永久免费观看| 国产白丝无码免费视频| 成全在线观看免费观看大全| 最近免费中文字幕中文高清| 成人精品综合免费视频| 特级毛片爽www免费版| 无码精品人妻一区二区三区免费| 亚洲av无码成人精品国产| 亚洲成a人无码亚洲成www牛牛 | 国产做床爱无遮挡免费视频| 暖暖日本免费在线视频| 波多野结衣久久高清免费| 国产福利免费在线观看| 可以免费观看一级毛片黄a| 天堂亚洲免费视频| 亚洲熟伦熟女新五十路熟妇| 亚洲国产成人久久一区WWW| 精品亚洲一区二区三区在线播放| 久久亚洲AV无码西西人体|