查询的自定义结果需要插入到新表,但是还得自己定义新表,懒得手工创建表,则使用语句快速建表,然后再去调整表结构
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...
一般情况下,绝大部分,我们的主键是数字,1 2 3 4...所以我们才让它递增.这并不意味着,他们两个必须要绑定在一起使用.例如我还想将用户表的email字段设置为主键,但是并没有必要为其设置自增。 因此可...
1.查看歌曲表结构(主要是给name字段添加全文索引)(mysql5.7才支持全中文索引)desc music; +---------+-------------+------+-----+---------+----------------+ | Fie...
已有表名log来记录用户日志,id是主键,uid是用户id,rmk是备注,addtime是时间戳,需要取出不重复的用户日志记录默认的结果集:id uid rmk ...
(1).下面是一张基本的会员表membermid name age 1 高峰 24 2 王小 19 3 韩星 24(2).下面是一张基本的会员日志表loglid ...
(1).查询某个字段是否包含某个字符串,可以直接使用likeSELECT oid,oname from zhongxing_options where oname li...