user1449281
user1449281

Reputation: 39

MYSQL Query execution time

HI I have a MYSQL Query which has a long response time. I have a table for_reg_users which has different fields like first name, last name and date visited. I run the query to get records which are new( i-e: before particular time period they do not have a entry and the record should be unique so the first name and last name is combined). Can this query be written in different way so that the response time is less. Thanks in advance.

Query = SELECT * FROM `for_reg_users` where `date_visited` BETWEEN '2012-05-01' AND '2012-05-31' AND CONCAT(first_name, ' ', last_name) NOT IN ( SELECT CONCAT(first_name, ' ', last_name) from `for_reg_users` where `date_visited` < '2012-05-01') AND `deleted` = '0';

Upvotes: 0

Views: 530

Answers (1)

Shehzad Bilal
Shehzad Bilal

Reputation: 2523

Query = SELECT DISTINCT(CONCAT(first_name, ' ', last_name)) , * FROM `for_reg_users` where `date_visited` <= '2012-05-31' and deleted = 0

Upvotes: 1

Related Questions