[英]how to create table column that is a list of items from another table
I need to make a database table for a small invoice app i am making, and I made a table called "Invoice" which stores all my invoices. 我需要为正在制作的小型发票应用程序制作数据库表,然后制作了一个名为“发票”的表,该表存储了所有发票。 It has a column called "items" which should be a list of items invoiced to the customer.
它有一个称为“项目”的列,该列应该是向客户开票的项目清单。 ie "Camera, film, lens".
即“相机,胶片,镜头”。
The items are located on another table called "Items" which has "item_name" and "Item_id". 这些项目位于另一个名为“ Items”的表上,该表具有“ item_name”和“ Item_id”。
How can I make the "items" column in "Invoice" store a list of Items? 如何使“发票”中的“项目”列存储项目列表?
Thanks 谢谢
对外键进行一些研究,并尝试在您的方案中实现它们。
You need to join your tables. 您需要加入表格。 You will do this using Your Primary Key of one table and a foreign key in another.
您将使用一个表的主键和另一个表的外键来执行此操作。 Use the below formula.
使用以下公式。
'SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name=table2.column_name;'
You will then use the below formula to select your data into a new table. 然后,您将使用以下公式将数据选择到新表中。
'SELECT *
INTO newtable [IN externaldb]
FROM table1;'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.