1
select id from customer_details where store_client_id = 2 
And
    id  NOT IN (select customer_detail_id from  orders 
        where store_client_id = 2 and total_spent > 100 GROUP BY customer_detail_id ) 
Or
    id IN (select tcd.id from property_details as pd, customer_details as tcd 
        where pd.store_client_id = 2 and pd.customer_detail_id = tcd.customer_id and pd.property_key = 'Accepts Marketing' 
        and pd.property_value = 'no') 
And 
    id IN (select customer_detail_id from orders 
        where store_client_id = 2 GROUP BY customer_detail_id HAVING count(customer_detail_id) > 0 ) 
Or
    id IN (select tor.customer_detail_id from ordered_products as top, orders as tor 
        where tor.id = top.order_id and tor.store_client_id = 2 
        GROUP BY tor.customer_detail_id having sum(top.price) = 1)`

I have this mysql query with inner join so when it run in mysql server it slow down what is the issue cant find.
But after 4-5 minutes it return 15 000 records. This records is not an issue may be.
In some tutorial suggest to use Inner join, Left join,... But I don't know how to convert this query in Join clause. Any help will be appreciated. Thanks in advance.

0

1 Answer 1

1

First of all please read relational model and optimizing select statements.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.