insert select구문을 update select 구문형태로 변경 도와주세요.
본문
안녕하세요. 무더위에 건강챙기세요..
한가지 문의드릴께 있어서 글 남깁니다.
$opt_sql = " insert ignore into {$g5['g5_shop_item_option_table']} ( io_id, io_type, it_id, io_price, io_stock_qty, io_noti_qty, io_use )
select io_id, io_type, '$new_it_id', io_price, io_stock_qty, io_noti_qty, io_use
from {$g5['g5_shop_item_option_table']}
where it_id = '$it_id'
order by io_no asc ";
sql_query($opt_sql);
기존옵션을 업데이트 하는 형태로 바꾸려는데...
위와 같은 구문을 update select 구문으로 변경하려는데.. 도움말씀부탁드립니다.
답변 1
INSERT ... ON DUPLICATE KEY UPDATE 를 사용하세요.
https://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html
답변을 작성하시기 전에 로그인 해주세요.