PHP-MySQL 3表选择、更新、删除和插入与外键链接
我在 MySQL 中与外键链接的 3 个 InnoDB 表上遇到问题,我的表是:
Table1 name - products
PID(PK, bigint, auto inc),
CATALOG_NO,
PRODUCT_NAME,
COMPOSITION,
SIZE,
PRICE,
SUBCAT_ID(foreign Key, index, bigint, keyname-FK_products_1)
Table2 name - subcategory
SUBCAT_ID(PKey, bigint, auto inc),
SUBCATEGORY_NAME, CAT_ID(fkey, bigint)
Table3 name - category
CAT_ID(Pkey, bigint, auot inc),
CAT_NAME
1.什么是 SELECT 的正确查询并通过连接 3 个表列出数据,其结果应显示为:
ProductsPID, CATALOG_NO, PRODUCT_NAME, COMPO, SIZE, PRICE, SUBCATEGORY_NAME, CAT_NAME
2.正确的方法是什么通过一个表单使用一个查询来更新和删除上述连接记录?
3.是否可以使用包含产品名称(输入类型=文本)、目录号(输入类型=文本)、成分(输入类型=文本)、尺寸(输入类型=文本),价格(输入类型=文本),选择子类别(选择带选项的类型字段),类别(选择带选项的类型字段)如果是,那么如何?
请帮忙,很紧急。
I have a problem with 3 InnoDB tables in MySQL linked with a foreign key, My tables are:
Table1 name - products
PID(PK, bigint, auto inc),
CATALOG_NO,
PRODUCT_NAME,
COMPOSITION,
SIZE,
PRICE,
SUBCAT_ID(foreign Key, index, bigint, keyname-FK_products_1)
Table2 name - subcategory
SUBCAT_ID(PKey, bigint, auto inc),
SUBCATEGORY_NAME, CAT_ID(fkey, bigint)
Table3 name - category
CAT_ID(Pkey, bigint, auot inc),
CAT_NAME
1.What is the right query to SELECT and list the data by joining 3 tables which should display result as:
ProductsPID, CATALOG_NO, PRODUCT_NAME, COMPO, SIZE, PRICE, SUBCATEGORY_NAME, CAT_NAME
2.What is the correct way to UPDATE and DELETE the above joined records by using one single query through one single form?
3.Is it possible to insert the records also through single query by using single html form containing fields such as product name (input type=text), catalog no (input type=text), composition (input type=text), size (input type=text), price (input type=text), Choose subcategory (select type field with options), category (select type field with options) if yes then how?
PLEASE HELP, ITS URGENT.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在某些情况下,更新和删除也可以使用联接(不是在外键上),但您可能只需要更改产品表。插入必须位于各个表上。
update and delete can also use join in some cases (not on foreignkeys) but you probably only need to change the product table. insert has to be on the individual tables.