Re: Narrow A First Set Of Records

2015-12-17 Thread Roy Lyseng
Hi Don, On 17.12.15 16.14, Don Wieland wrote: Hey gang, I need the ability to produce this end result: condition a) All clients who have had at least 2 appointments in the last 24 months condition b) of the set of “condition a” rows, which of those have NO appointments in the last 6 months

Re: Query optimizer-miss with unqualified expressions, bug or feature?

2015-10-19 Thread Roy Lyseng
Hi Ben, On 19.10.15 15.10, Ben Clewett wrote: I have noticed that an unqualified boolean expression cannot be optimized by MySQL to use an index in 5.6.24. For example: CREATE TABLE t ( i INT NOT NULL AUTO_INCREMENT PRIMARY KEY, a BOOLEAN NOT NULL, KEY a (a) ) ENGINE=InnoDB; This

Re: Query optimizer-miss with unqualified expressions, bug or feature?

2015-10-19 Thread Roy Lyseng
Hi Shawn, On 19.10.15 22.33, shawn l.green wrote: On 10/19/2015 3:48 PM, Roy Lyseng wrote: Hi Ben, On 19.10.15 16.07, Ben Clewett wrote: Hi Roy, Thanks for the clear explanation. I guess (hypothetically) the optimizer could see if it has a key, and then use two starts: one on 'a >

Re: Query optimizer-miss with unqualified expressions, bug or feature?

2015-10-19 Thread Roy Lyseng
0' would easily be transformed to a = 1. It would also mean that statistics for the columns would be better, with TINYINT each value has the estimated probability 1/256, whereas a boolean value would have probability 1/2. Thanks, Roy Ben. On 2015-10-19 14:19, Roy Lyseng wrote: Hi Ben, On

Re: Precedence in WHERE clauses.

2014-03-20 Thread Roy Lyseng
Hi Christophe, On 20.03.14 13:18, Christophe wrote: Hi Michael, Le 18/03/2014 20:28, Michael Dykman a écrit : Also, as you currently have it, the expression DATE_SUB(NOW(), INTERVAL 24 is going to be executed once for every single candidate row. I would suggest you temporarily memoize that

Re: Narrowing a SELECT statement by multiple hits

2014-02-17 Thread Roy Lyseng
Hi Jennifer, please try filtering with a subquery that locates ip addresses with more than 1 attempt: SELECT ip, page, url, time_stamp FROM ip_adresses WHERE existing where clause AND ip IN (SELECT ip FROM ip_addresses WHERE existing where clause

Re: Narrowing a SELECT statement by multiple hits

2014-02-17 Thread Roy Lyseng
Hi Jennifer, great that it worked. Try replacing the line `ip` IN (temp_ip) with `ip` IN (SELECT ip FROM temp_ip) Each subquery needs to be a complete SELECT query. Thanks, Roy On 17.02.14 21:11, Jennifer wrote: On Feb 17, 2014, at 10:17 AM, Roy Lyseng wrote: please try filtering

Re: Strange date behaviour

2011-03-31 Thread Roy Lyseng
On 31.03.11 12.52, Andrew Braithwaite wrote: Hi, Mysql select curdate() + interval 6 month - interval 6 month; +-+ | curdate() + interval 6 month - interval 6 month | +-+ | 2011-03-30

Re: Need help with query

2011-03-19 Thread Roy Lyseng
Hi! I think that the query that you have proposed is the best possible for the problem. However, if there are duplicates in the orders table, then HAVING COUNT(item_id) = 4 should be replaced with HAVING COUNT(DISTINCT item_id) = 4 (I assume that you meant item_id and not org_id in the

Re: a crash bug

2011-02-28 Thread Roy Lyseng
Hi zhongtao, thank you for reporting this bug. It has been filed as http://bugs.mysql.com/bug.php?id=60279 Regards, Roy On 24.02.11 08.08, tanzhongt wrote: create table t1(a int); create table t2(b int); PREPAREstmt FROM select sum(b) from t2 group by b having b in (select b from

Re: WL#946 and Changing time literal format

2009-01-25 Thread Roy Lyseng
Michael Widenius wrote: Hi! Peter == Peter Gulutzan peter.gulut...@sun.com writes: Peter Hi all, Peter On 01/15/2009 03:11 PM Peter Gulutzan wrote: For a TIME or DATETIME or TIMESTAMP literal, one can use '.' instead of ':' and one can skip leading fields. For example: INSERT INTO t