MySQL Forums
Forum List  »  Optimizer & Parser

Re: Optimizing query
Posted by: Scott Nemes
Date: February 24, 2012 01:16PM

I can't say if this will be faster or not without having the actual data to test it on, but it's worth a shot. Basic idea is you use group_concat to pool all the statuses together and then check the resulting string for what you want to include/exclude:

select
group_concat(status) as `statusComb`,
name,
surname,
address
from <table>
where city = 'Detroit'
group by name,surname,address
having (statusComb like "%owner%" or statusComb like "%renting%")
and statusComb not like "%evicted%"
and statusComb not like "%moved%";

--
Scott Nemes
MySQL DBA

http://www.linkedin.com/in/scottnemes
http://www.twitter.com/ScottNemes

Options: ReplyQuote


Subject
Views
Written By
Posted
2185
February 24, 2012 06:07AM
Re: Optimizing query
1223
February 24, 2012 01:16PM
1102
February 25, 2012 03:49AM
1452
February 27, 2012 05:57AM
1197
February 25, 2012 05:54PM
1116
February 27, 2012 06:04AM
1211
February 28, 2012 07:57PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.