Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: SQL
Posted by: Влад Якуб
Added: Oct 2, 2019 4:02 PM
Modified: Oct 2, 2019 4:02 PM
Views: 4
Tags: no tags
  1. INSERT INTO `profi_audit`.`user`
  2. SELECT
  3.         `u`.`id`
  4.         ,`u`.`lastname`
  5.         ,`u`.`name`
  6.         ,IF(`u`.`sex`=1,'male',IF(`u`.`sex`=2,'female',NULL)) AS `gender`
  7.         ,TIMESTAMPDIFF(
  8.                 YEAR,
  9.                 CONCAT_WS('-',YEAR(`u`.`birthday`),IF(MONTH(`u`.`birthday`),MONTH(`u`.`birthday`),'01'),IF(DAY(`u`.`birthday`),DAY(`u`.`birthday`),'01')),
  10.                 CURDATE()
  11.         ) AS `age`
  12.         ,`u`.`city`
  13.         ,concat('{"0":"',`u`.`phone`,'"}') AS `phones`
  14.         ,100 AS `karma`
  15.         ,'' AS `extra`
  16. FROM    `profi_research`.`user` AS `u`
  17. WHERE   `u`.`id` IN (111);
  18.  
  19.  
  20. INSERT INTO `profi_audit`.`answer`
  21. SELECT
  22.         `a`.`user`,`a`.`research` AS `survey`,`a`.`question`,`a`.`answer`
  23. FROM    `profi_research`.`survey_answer` AS `a`
  24. WHERE   `a`.`research`  = 3286
  25. AND             `a`.`user`              IN (SELECT `id` FROM `profi_audit`.`user`)
  26. AND             `a`.`question`  IN (96,3432,3433,3434,3435,3436,3437,3438,3439,3440,3441,3442,3443,3452,3453)
  27.