csvで足りないデータ をsqlで他テーブルから取得し、そのままconcatでinsert文を作る
・エクセルのデータでselect(1行目) ~ union all select(2行目以降) を大量に作る
・↑で作った、select文をsqlで実行
・↑をテーブルとし、joinして必要なデータを取得する。
・concat文で結合し、insert文を作る。
select concat('insert文を作る') from ( select id,... union all select id,... .....//繋げる ) excel_data ed join users on ed.excel_user_id = users.id
先輩に助けられた日でした。