Multiple MySql AND Statements

meno19
meno19 used Ask the Experts™
on
I know the syntax is not correct. How would I go about using multiple and statements?

SELECT * FROM `search` WHERE company_name LIKE '%pizza%' 
and 
latitude BETWEEN 38.69852058020537 AND 41.224260426268195 
AND 
longitude BETWEEN -75.97329101562502 AND -75.97329101562502 
LIMIT 0, 25

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2012
Commented:
I can't see anything wrong with it - what error message did you get?

Author

Commented:
Sneaky Bastard doesn't throw and error. Sometimes the query runs and does not return results. It doesn't look to be the query its a glitch in how I'm triggering a search.

Author

Commented:
Dammit i figured it out, bringing in the wrong number for the search
Top Expert 2012

Commented:
That confirms that the syntax is correct.  Maybe start with one clause first (the LIKE) and see if there are results.  Then add the latitude filter and see what's left, then add the last filter.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial