国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

mysql - Sql union 操作

瀏覽:119日期:2022-06-14 10:08:09

問題描述

問題:第一種寫法:

(select du.day,du.apptoken ,du.version, du.channel,du.city,du.count,concat(apptoken, version,channel,city) as joinkey from day_new_users_count du where day=’20170319’) as dayUsers union (select tu.day,tu.apptoken,tu.version,tu.channel,tu.city,tu.count,concat(apptoken,version,channel,city) as joinkey from total_users tu where day=’20170318’) as toUsers

第二種寫法:

select du.day,du.apptoken ,du.version, du.channel,du.city,du.count,concat(apptoken, version,channel,city) as joinkey from day_new_users_count du where day=’20170319’ union select tu.day,tu.apptoken,tu.version,tu.channel,tu.city,tu.count,concat(apptoken,version,channel,city) as joinkey from total_users tu where day=’20170318’

為什么第二種寫法可以正確執行,第一種方式就不可以??

區別 不是 第一種方式中給 臨時表起了個別名嘛,怎么就不行了?高人指點吶

問題解答

回答1:

select * from (selectdu.day, du.apptoken , du.version, du.channel, du.city, du.count,concat(apptoken, version,channel,city) as joinkeyfrom day_new_users_count duwhere day=’20170319’) as dayUsersunionselect * from (selecttu.day, tu.apptoken, tu.version, tu.channel, tu.city, tu.count,concat(apptoken,version,channel,city) as joinkeyfrom total_users tuwhere day=’20170318’) as toUsers

相關文章:
主站蜘蛛池模板: 塔河县| 黄龙县| 遂平县| 行唐县| 封丘县| 新晃| 宁波市| 陆良县| 湘西| 元阳县| 潮安县| 西丰县| 拜城县| 商水县| 盐亭县| 兴安县| 勐海县| 卓资县| 拜城县| 出国| 天气| 青阳县| 卫辉市| 逊克县| 新昌县| 桃源县| 乌兰县| 左贡县| 商洛市| 潞城市| 灵丘县| 喀什市| 沂源县| 葫芦岛市| 迁西县| 舟曲县| 吕梁市| 通城县| 遂溪县| 咸宁市| 梨树县|