gpt4 book ai didi

html - 如何自动将相同的自动递增 ID 存储在两个不同的表中?

转载 作者:行者123 更新时间:2023-11-30 22:55:23 24 4
gpt4 key购买 nike

所以,事情是:

我正在建立一个在线市场,它在同一个市场上有几家商店,为此我想识别每家商店和他们拥有的每一种产品,问题是我有一个表格,他们可以回答所有问题并将其重定向数据到sql关系数据库。

所以,例如:

The form could be something like this ( I'm still thinking how I'm going to do this ):

name
product1 / price
product2 / price
.
.
.
productN / price


And the database having this base structure:

STORES PRODUCTS STORE/PRODUCT
----------- ----------- --------------
ID name: Pcode Pname: ID PID Price
1 store1 100 product1 1 101 50$
2 store2 101 product2 1 103 20$
3 store3 102 product3 2 103 25$

(ID is autoincrementing )

因此,在这种形式下,商店经理将插入他需要的所有数据,并将这些数据放在我的 mysql 表中。

问题是:

我不知道如何在几个不同的表中插入相同的 ID,因为 ID 是自动递增的。

有人对执行此操作的 sql 命令有建议吗?

最佳答案

http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html

You can retrieve the most recent AUTO_INCREMENT value with the LAST_INSERT_ID() SQL function or the mysql_insert_id() C API function. These functions are connection-specific, so their return values are not affected by another connection which is also performing inserts.

关于html - 如何自动将相同的自动递增 ID 存储在两个不同的表中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26621004/

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