久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

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

mysql - Sql union 操作

瀏覽:112日期: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

相關文章:
主站蜘蛛池模板: 保德县| 辽阳市| 彭山县| 松溪县| 吴桥县| 虞城县| 屯昌县| 依兰县| 侯马市| 昭觉县| 邵阳县| 苏尼特右旗| 衡阳市| 扶余县| 水富县| 阳信县| 锦州市| 永州市| 丰宁| 根河市| 雅安市| 新平| 民县| 虞城县| 秭归县| 渝中区| 化隆| 佛学| 庆元县| 遂昌县| 鄂托克旗| 太仆寺旗| 高安市| 吴江市| 兴城市| 泸定县| 红安县| 循化| 正安县| 淮安市| 洛浦县|