Oracle语句转换成MySQL语句问题

哪位大佬,有时间帮帮忙啊,MySQL小白 :
insert into TEMP_BD_DAT_HMMY (R_ANIMAL, pig_id_from, FARM_ID)
SELECT pig_id, 1, farm_id from (select row_number() over(PARTITION BY pig_id order by arr_date desc) rn,
pig_id,farm_id from T_BOAR_PIGINFO_MOVED
where (BOR_DATE >= to_date('2016-7-19','YYYY-MM-DD')
and BOR_DATE <= to_date('2019-7-19','YYYY-MM-DD') )
and BREED_CODE ='MM'
and FARM_ID in ('530001', '100301')
and length(Dadid) > 0
and length(MaId) > 0
and sex in (0, 1)
and exists (select 1
from T_BREED_GROWTH a
where a.pig_id = T_BOAR_PIGINFO_MOVED.pig_id
and a.TEST_WT_END >= 85
and a.TEST_WT_END <= 130
and a.AVERAGE_BFT >= 4
and a.AVERAGE_BFT <= 30
and a.test_days_end >= 100
and a.test_days_end <= 300)
and not exists
(select 1
from TEMP_BD_DAT_HMMY x
where x.R_ANIMAL = T_BOAR_PIGINFO_MOVED.pig_id)) a
where a.rn = 1
帮我把这Oracle 语句改成MySQL的 谢谢了

1个回答

第二行的 高级查询over(PARTITION BY 改成关联查询。
时间转换的to_date 改成 str_to_date(date,'%Y-%m-%d') 。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问