我想创建一个包含所有产品评级和用户购买记录的数据库
假设我创建了一个名为“Users_rating_product”的表,其中包含一些列
user_id ->INT
company->Varchar
product1 -> 3 (rating of product out of 5)|(review of product)
product2-> 4(rating)|(some review)
我想知道如何在 mysql 中执行此操作。我正在使用 phpmyadmin 创建数据库
表格看起来像
user_id | company |Ac | TV | fridge
1 | goderaj |3 ,take more power |4,less power |5,efficient
我想知道我该怎么做才能让产品的评级和注释显示在同一列中
最佳答案
为此,您需要一个单独的表格。将其命名为 ProductRating
。将唯一键 (ID
) 放入表并将该键引用到您的 Users_rating_product
表。
例如:
Users_rating_product:
user_id | company |Ac | TV | fridge
1 | goderaj |1 | 2 | 3
2 | somecomp |4 | 5 | 6
产品评级
ID | Rating | Review
1 | 3 | Take more power
2 | 4 | less power
3 | 5 | efficient
4 | 5 | excellent
5 | 1 | awful
6 | 3 | average
关于mysql - sql表的同一列如何添加两个字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26672063/