HEX
Server: Apache/2.2.15 (CentOS)
System: Linux ip-10-0-2-146.eu-west-1.compute.internal 2.6.32-754.35.1.el6.centos.plus.x86_64 #1 SMP Sat Nov 7 11:33:42 UTC 2020 x86_64
User: root (0)
PHP: 5.6.40
Disabled: NONE
Upload Files
File: /www/exchange2/sql/archive/2016-01-14-271.sql
ALTER TABLE `user_login`  CHANGE COLUMN `user_id` `user_id` SMALLINT(20) UNSIGNED NOT NULL AUTO_INCREMENT FIRST;

INSERT INTO temp_registration (temp_reg_id,username,password,register_type,organization_name,organization_address_id,user_type,status,permission,created_at,doj)
SELECT NULL, LEFT(organisation_name,10),LEFT(organisation_name,10),0, organisation_name, organisation_address_id,7,4,1,NOW(),NOW()
FROM organisation_details
WHERE type=6;

UPDATE `temp_registration`
SET `ref_id` = (CONCAT(DATE_FORMAT(doj,'%Y%m%d'), '000000') + temp_reg_id)  
WHERE ref_id IS NULL AND user_type=7;

INSERT INTO user_login (user_id,username,user_password,user_type,user_status)
SELECT NULL,username,password,user_type,1
FROM temp_registration
WHERE user_type=7;

UPDATE temp_registration
LEFT JOIN user_login ON user_login.user_type = temp_registration.user_type AND temp_registration.username = user_login.username AND temp_registration.password = user_login.user_password
SET temp_registration.user_id = user_login.user_id
WHERE temp_registration.user_type=7;

UPDATE organisation_details 
LEFT JOIN temp_registration ON temp_registration.organization_address_id = organisation_details.organisation_address_id
SET organisation_details.user_id = temp_registration.user_id
WHERE temp_registration.user_type=7;