简体   繁体   English

MySql获取加扰结果

[英]MySql Get scrambled results

Current scenario : 当前场景:

I have a MySQL database (products_db) with product links ('links') . 我有一个带有产品链接('links')的MySQL数据库(products_db)。 Now the products / links are from 11 different websites (advertisers). 现在,产品/链接来自11个不同的网站(广告商)。

Is there some sort of MySQL query I can make to get the results in groups of 11 links, one link for each website ? 我是否可以进行某种MySQL查询以11个链接的组的形式获得结果,每个网站一个链接?

The point is to get a list of results with all the links, one link for each 11 website . 关键是要获得包含所有链接的结果列表,每个11个网站一个链接。

I know I can use the following to get the first 11 rows each from a different website, but I need ALL the results arranged like that . 我知道我可以使用以下代码从不同的网站获取前11行,但是我需要按这样排列的所有结果。

SELECT id, name, advertiser, link
FROM table
GROUP BY advertiser

If not, I guess I have to go back to sort the list in PHP .. 如果没有,我想我必须回去对PHP中的列表进行排序。

thanks! 谢谢!

使用group by而不是order by

SELECT id, name FROM table GROUP BY id

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM