gpt4 book ai didi

mysql - Insert into with select(准备好的语句)

转载 作者:行者123 更新时间:2023-11-29 02:20:38 24 4
gpt4 key购买 nike

我想要这个查询:

INSERT INTO
users_groups (user_id, group_id)
VALUES
(?, (SELECT group_id FROM groups WHERE group_name = ?))

表格:

users_groups:
| user_id | group_id |

groups
| group_id | group_name |

我怎样才能让它工作?

最佳答案

试试这个;

INSERT INTO
users_groups (user_id, group_id)
VALUES
(SELECT ?, group_id FROM groups WHERE group_name = ?)

关于mysql - Insert into with select(准备好的语句),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32462433/

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