php - Select where rows exist more than once with variation -


this hard 1 put title apologise ambiguity.

i have following mysql table (it's magento table):

id    attr_id  store_id   entity_id     value ----+---------+---------+------------+------------------------ 1   45      0           173         sale gifts + apartment 2   45      0           175         sale outerwear 3   45      1           175         sale outerwear 4   45      0           177         (null) 5   45      1           177         new arrivals 6   45      0           178         new tops 7   45      1           178         new tops 

as can see, of rows have same except store_id.

i want following:

  1. if row store_id = 0 has duplicate row, store_id = 1 , different values (for example, rows 4 , 5 above), update row store_id = 0 have same value other.

  2. delete row store_id = 1

i know need combination of both php , mysql this. don't know mysql query be.

any great!

edit

the end goal above table following

id    attr_id  store_id   entity_id     value ----+---------+---------+------------+------------------------ 1   45      0           173         sale gifts + apartment 2   45      0           175         sale outerwear 4   45      0           177         new arrivals 6   45      0           178         new tops 

in order retrive redundunt values having same entity_id, can :

select   *   magento m1, magento m2     m1.attr_id=m2.attr_id ,    m1.entity_id=m2.entity_id ,     m1.id > m2.id 

and fixing null values, need loop above results , search null , replace previous or next result.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -