gpt4 book ai didi

mysql - 作为连接查询插入后如何获取最大值

转载 作者:行者123 更新时间:2023-11-29 21:10:25 25 4
gpt4 key购买 nike

INSERT INTO `idt_lookup`(`idt_resources`, `idt_lookup_name`, `idt_lookup_tbl_name`, `idt_lookup_key_col`, `idt_lookup_val_col`, `last_upd_by`, `last_upd_datetime_utc`) VALUES ('" + resourceId + "','" + roltbl + "','" + roltbl + "','" + rolid + "','" + rolname + "','1','" + date1 + "')

SELECT MAX(`idt_lookup_id`) AS maxid FROM `idt_lookup

我如何加入这两个查询。这可能吗?

最佳答案

尝试示例查询:-

$insertQuery = "
INSERT INTO owner_business_media
(business_id, sequence, type, filename, title, secret)
SELECT
'".intval($_GET['businessid'])."',
(SELECT MAX(obm.sequence)+1 FROM owner_business_media obm WHERE obm.business_id=".intval($_GET['businessid']).") AS next,
'$type',
'$fullfile',
'$filename',
'1'
";

希望这会有所帮助......!!

关于mysql - 作为连接查询插入后如何获取最大值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36417412/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com