MySQL에서 Insert, Update 할 때에 Select문을 이용하면 훨씬 유용하다.

UPDATE
     QUESTION q, medication.`form_fsq` f 
SET 
     q.FORM_form_ID = f.`form_pk` 
WHERE 
     q.`question_ID` = f.`fsq_id`;

INSERT INTO CONCEPT(concept_type, source_ID, source_CD, source_name, ref_source_ID)  
	SELECT 'LAB', lab_ID, lab_CD, lab_name, 1 FROM LAB;

+ Recent posts