PHP Group by和列出所有其他列

时间:2015-10-19 19:46:32

标签: php mysql

我有一张桌子: enter image description here

选择数据库是:

$select_table2 = '
SELECT e.product_clicks
     , e.product_id
     , e.website_url
     , u.name
     , u.product_id 
 FROM `oc_aa_affiliatecollclicktracking` AS e 
 LEFT      
 JOIN  `'.DB_PREFIX.'product_description` AS u 
    ON e.product_id = u.product_id 
 GROUP 
    BY e.website_url';

这会对其进行分组,但不会列出所有product_id

我明白了:

http://127.0.01
        36

我想对其进行分组,但请查看所有product_id

http://127.0.01
    36
    40
    33

1 个答案:

答案 0 :(得分:0)

$select_table2 = 'SELECT `product_id` FROM `oc_aa_affiliatecollclicktracking` WHERE website_url LIKE '%http%';

如果您不想重复product_id

$select_table2 = 'SELECT DISTINCT(`product_id`) FROM `oc_aa_affiliatecollclicktracking` WHERE website_url LIKE '%http%';