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

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

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

    2011年11月23日

    (轉貼)數據庫連接(內連接,外連接,交叉連接)

    數據庫連接分為:內連接,外連接(左、右連接,全連接),交叉連接
    文章地址 : http://www.zxbc.cn/html/20080527/51189.html
    轉載 
    內連接:把兩個表中數據對應的數據查出來 
    外連接:以某個表為基礎把對應數據查出來(全連接是以多個表為基礎) 
    student表 
    no name 
    1     a 
    2     b 
    3     c 
    4     d 
    grade表 
    no grade 
    1     90 
    2     98 
    3     95 
    內連接 inner join(查找條件中對應的數據,no4沒有數據不列出來) 
    語法:select * from student inner join grade on student.no = grade.no 
    結果 
    student.no name grade.no grade 
    1             a             1         90 
    2             b             2         98 
    3             c             3         95 
    左連接(左表中所有數據,右表中對應數據) 
    語法:select * from student left join grade on student.no = grade.no 
    結果: 
    student.no name grade.no grade 
    1                 a         1         90 
    2                 b         2         98 
    3                 c         3         95 
    4                 d     
    右連接(右表中所有數據,左表中對應數據) 
    語法:select * from student right join grade on student.no = grade.no 
    結果: 
    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 
    結果: 
    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 將左連接和右連接合并后才可以

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

    行數應該為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 閱讀(490) | 評論 (0)編輯 收藏

    JAXB向Xml非根節點添加一個或多個屬性

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

    原創文章,轉載請注明出處。http://www.tkk7.com/kangdy/archive/2011/11/23/364635.html

    code1: colors類  根節點
    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類  子節點
    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 子節點
    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());

        }
    }

    運行結果:
    結果
    <?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 閱讀(10126) | 評論 (4)編輯 收藏

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

    導航

    統計

    常用鏈接

    留言簿

    隨筆分類

    隨筆檔案

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: a级毛片黄免费a级毛片| 人人爽人人爽人人片A免费| 久久久精品免费国产四虎| 亚洲国产aⅴ综合网| 精品一区二区三区无码免费直播 | 国内精品免费在线观看| 在线亚洲人成电影网站色www | 中文字幕乱码系列免费| 亚洲精品tv久久久久久久久| 伊人久久大香线蕉免费视频| 亚洲国产综合无码一区| 一级毛片免费不卡在线| 精品亚洲aⅴ在线观看| 成年人免费的视频| 亚洲色大情网站www| 亚洲AV成人潮喷综合网| 国产成人无码区免费网站| 亚洲人成网址在线观看| 青草草色A免费观看在线| 亚洲精品美女久久7777777| 免费在线观看一级毛片| 在线看片免费人成视频久网下载| 亚洲成a人片77777老司机| 国产91免费视频| 免费人成再在线观看网站 | 中文字幕无码日韩专区免费| 无码久久精品国产亚洲Av影片| 精品无码国产污污污免费网站| 亚洲av永久无码精品天堂久久| 日日夜夜精品免费视频| 久久精品成人免费观看97| 亚洲麻豆精品果冻传媒| 美女视频黄的全免费视频网站| 日韩亚洲人成网站| 亚洲成亚洲乱码一二三四区软件| 最刺激黄a大片免费网站| 亚洲色偷偷综合亚洲av78 | 亚洲熟妇色自偷自拍另类| 四虎永久免费观看| 任你躁在线精品免费| 亚洲午夜国产精品|