php - mysql group by any one or more of several fields -


i looking group following criteria:

so lets have how can group them product1,brand1,null,null,12,null,1234

product2,brand1,null,null,12,null,null  product3,brand2,null,null,null,1234  product1,brand1,null,null,null,null,null   (product_name , brand_name) upc or isbn or mpn or ean or model_number  

is possible create single select statement return these grouped values ?

many in advance

the short answer "no." how mysql know 1 want group in particular situation? wouldn't. need send mysql different sql query each situation.

if in ui user chose group 1 thing, send mysql query group that. if chose group else, send mysql query group that. have choose in php before tell mysql do. can't expect mysql read mind , know "in case wants group x."

you can, however, group fields, giving them priority. i.e. group 1 first, one, etc. like:

select * products  group  product_name, brand_name, upc, isbn, mpn, ean, model_number 

but not going group 1 or other. group of them, giving first priority first mentioned.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -