Jump to content

[SOLVED] MySQL Query


PatPHP

Recommended Posts

To utilize an index, you need it in the form:

 

SELECT * FROM table WHERE column1 BETWEEN expr1 AND expr2

 

So you have to move it around so one of the columns in being compared against the expressions (which can also contains column references).  Sometimes this means you have to add a 2nd part to the where clause.

 

So

 

SELECT * FROM table WHERE startDate >= NOW() and endDate < NOW()

 

Is "better", though it does obscure the logic a bit.

 

check EXPAIN.

Link to comment
https://forums.phpfreaks.com/topic/114610-solved-mysql-query/#findComment-589782
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.