查询的自定义结果需要插入到新表,但是还得自己定义新表,懒得手工创建表,则使用语句快速建表,然后再去调整表结构
create TABLE app.dm_x2_vip_check_res as SELECT a.vip_id AS x2_vip_id, a.vip_mobile AS x2_vip_mobile, a.channel_brand AS x2_channel_brand, a.grade_id AS x2_grade, a.vip_birth_date AS x2_vip_birth_date, a.depot_id AS x2_depot_id, a.extend_user_id AS x2_extend_user_id, b.vip_id AS dm_vip_id, b.vip_mobie AS dm_vip_mobile, b.channel_brand AS dm_channel_brand, b.grade_code AS dm_grade_id, b.vip_birthday AS dm_vip_birth_date, b.depot_id AS dm_depot_id , b.clerk_code AS dm_extend_user_id FROM dim.dim_vip a INNER JOIN dim.dim_vip_dm b ON a.vip_id = b.vip_id AND ( a.vip_mobile != b.vip_mobie OR a.channel_brand != b.channel_brand OR a.grade_id != b.grade_code OR a.vip_birth_date != b.vip_birthday OR a.depot_id != b.depot_id OR a.extend_user_id != b.clerk_code ) WHERE a.create_date < DATE_SUB( NOW(), INTERVAL 2 DAY ) ORDER BY a.create_date ASC
例如我们需要查询商品表中每个分类中商品id最大的记录,并且显示商品价格以下是表结构:id catename title &nb...
需求查询出存在商品的商品分类. 先看看分类表:id(分类的id) catename(分类名) 1 手机 2 &n...
Left join:即左连接,是以左表为基础,根据ON后给出的两表的条件将两表连接起来。结果会将左表所有的查询信息列出,而右表只列出ON后条件与左表满足的部分。左连接全称为左外连接,是外连接的一种。Right join:即右连接,是以右表为基础,根据ON后给出的两表的条件将两表连接起来。结果会将右表...
(1).首先我们需要了解limit分页的工作流程demo: SELECT * FROM table LIMIT 10000,5 通常我们会认为以上SQL会从10000条后面取5条,正确的是取出10005条,然后再抛弃前...
1.很多人认为count查询非常快,但是在加上筛选条件那就是未必的了!测试:user表中4000w数据(1).SELECT count(*) from user; 用时0.00s (2).SELECT...
项目和第三方系统对接,由于第三方开发人员属于兼职,数据库结构不一致的问题只能我来处理。此处文章用本地模拟演示。数据库资料:1号服务器: 账号root 密码root IP:127.0.0.1 数据库名称:data1 2号服务器...