mysql - Find and delete categories dont have product -


i have table in offer_category , product tables. want make query find offer_categories dont have product. on product have 170k rows , on offer_category table 3.6k

my query:

  select offer_category.title,product.name,offer_category.id     `offer_category` left join product on product.category_id =      offer_category.id product.id null 

when want run , browser running (i can see circle looping) 10 min not response anything.

how can make ?

your query seems fine:

  select oc.title, p.name, oc.id    `offer_category` oc left join         product p         on p.category_id = oc.id   p.id null; 

(i rewrote table aliases make more readable.)

the problem seem performance (or hanging connection database). improve performance, want index on product(category_id, id):

create index product_category_id_id on product(category_id, id); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -