mysql查询一个表的数据插入另一个表的写法

INSERT INTO `pl_member`.`membercardtype` (

  `hotelInfo_id`,

  `cardTypeName`,

  `cardType`,

  `discount`,

  `consumedPoints`,

  `createTime`,

  `lastModify`

此处没有values

(SELECT 

  t.`hotelInfo_id`,

  CASE

    WHEN t.vipCategary = 'JinKa' 

    THEN '金卡' 

    WHEN t.vipCategary = 'YinKa' 

    THEN '银卡' 

    WHEN t.vipCategary = 'PuTongJiFen' 

    THEN '普通积分' 

    WHEN t.vipCategary = 'ChuZhiKaHuiYuan' 

    THEN '储值卡会员' 

    WHEN t.vipCategary = 'DaZheKa' 

    THEN '打折卡' 

    WHEN t.vipCategary = 'JiFenKa' 

    THEN '积分卡' 

    WHEN t.vipCategary = 'YouHuiKa' 

    THEN '优惠卡' 

    WHEN t.vipCategary = 'JieJiKa' 

    THEN '借记卡' 

    ELSE '' 

  END cardTypeName,

  t.`vipCategary`,

  t.`discount`,

  1 AS `consumedPoints`,

  UNIX_TIMESTAMP(NOW())*1000 AS `createTime`,

  UNIX_TIMESTAMP(NOW())*1000 AS `lastModify` 

FROM

  member t 

GROUP BY t.`hotelInfo_id`,

  t.`vipCategary`)

你可能感兴趣的:(mysql)