简体   繁体   English

如何从两个表中获取数据并按第二个表Datamapper排序

[英]How to get data from two table and order by second table Datamapper

My first table is product and second table is user我的第一个表是产品,第二个表是用户
In product table column is id, user_id,prname etc;产品表列是id、user_id、prname等;
In user table column is id, user_name, rating.在用户表中的列是 id、user_name、 rating。

I used this for get我用这个来获取

$user = new User();
$user ->get();
$products = new Product();
$products ->get();

Now I want to get products order by user rating现在我想通过用户评分获得产品订单

you should create another table for rating where product id and user id and rating value must have with primary key rating id.您应该创建另一个用于评级的表,其中产品 id 和用户 id 以及评级值必须具有主键评级 id。

then select the product according to rating value.然后根据评级值选择产品。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何按第二个表的平均值显示两个表顺序的数据 - How to show data from two table order by average of second table 连接2个表以便从第二个表中获取所有数据 - joining 2 tables in order to get all the data from the second table 如何从具有两个字段的 MySQL 表中获取行以进行排序? - How to get rows from MySQL table with two field to order by? 如何使用GROUP BY和ORDER BY关键字从表中获取数据? - How to get data from table using GROUP BY and ORDER BY keyword? 如果第一张表中还有其他数据,如何从第二张表中获取单个值? - How to get single value from second table if data exists else from first table? 如果数据存在于第一个表中,如何从第二个表中获取价格? - How to get price from second table if data exists else from first table? 如何从第二个表中获取与第三个表共同的数据列,而第三个表在第一个表上有共同点? - How to get data column from second table that have common to the third table which third table have common on the first table? MySQL,如果第二个表并非总是具有匹配的行,则从两个相关的表中获取数据 - MySQL, get data from two related tables if second table not always have matching rows 如何基于第一张表匹配获取第二张和第三张表的数据 - How to get data of second and third table based of first table match 如何从 MySQL 中的第二个表打印数据 - how to print data from second table in MySQL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM