charmanraye
Technical User
I have two problems that are both SQL related using PHP.
1.) Tthe following SQL statement that returns NO RESULTS:
SELECT * FROM mytable WHERE (typeNum IS NOT NULL) AND (type LIKE '%Night Club%') AND (food LIKE '%American Contemporary%' OR food LIKE '%American Traditional%') ORDER by spot ASC LIMIT 14, 15
I have records where they typeNum is filled in, the type field has "Night Club" listed, and the food field contains "American Traditional"). However, the results contain no results.
Why does it return an empty set?
2.) I have a simple keyword search textbox that returns results in a field named spot. There are about 9,000 records, alphanumeric. Anyway, if I type in "de" in the keyword searchbox and hit search, it'll return things like:
Deer
depend
always decent
However, if I type "dee", the Deer record above won't show up; instead it'll return an empty set.
SELECT * FROM mytable WHERE (typeNumIS NOT NULL) AND (spot LIKE '%deer%' OR description LIKE '%deer%') ORDER by name ASC LIMIT 14, 15
Why is it returning an empty set for the search term, "dee"?
Am I using OR wrong?
1.) Tthe following SQL statement that returns NO RESULTS:
SELECT * FROM mytable WHERE (typeNum IS NOT NULL) AND (type LIKE '%Night Club%') AND (food LIKE '%American Contemporary%' OR food LIKE '%American Traditional%') ORDER by spot ASC LIMIT 14, 15
I have records where they typeNum is filled in, the type field has "Night Club" listed, and the food field contains "American Traditional"). However, the results contain no results.
Why does it return an empty set?
2.) I have a simple keyword search textbox that returns results in a field named spot. There are about 9,000 records, alphanumeric. Anyway, if I type in "de" in the keyword searchbox and hit search, it'll return things like:
Deer
depend
always decent
However, if I type "dee", the Deer record above won't show up; instead it'll return an empty set.
SELECT * FROM mytable WHERE (typeNumIS NOT NULL) AND (spot LIKE '%deer%' OR description LIKE '%deer%') ORDER by name ASC LIMIT 14, 15
Why is it returning an empty set for the search term, "dee"?
Am I using OR wrong?