Mysql Join limit on from table -


i'm having next mysql query

select     `i`.`id_item`,     `c`.`id_category` `items` `i`  left join `categories` `c` on c.id_category = i.id_category  (i.id_page = '7')  order `c`.`id_category` asc, `i`.`id_item` asc 

the items can belong category, or no category can defined them. need limit results items table x random values each category, or x random values if no category defined. how can this?

try using "group by" , use limit x values ( limit x). using x = 5;

select     `i`.`id_item`,     `c`.`id_category` `items` `i`  left join `categories` `c` on c.id_category = i.id_category  (i.id_page = '7') group i.id_category,i.id_item  order `c`.`id_category` asc, `i`.`id_item` asc limit 5 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -