Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Search Results Problem

Status
Not open for further replies.

charmanraye

Technical User
Feb 5, 2005
2
0
0
US
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?

 
the answer in both cases is: please show some sample rows so that we can test this for ourselves

use phpmyadmin's export feature to generate the CREATE TABLE and INSERT statements

you need not show all rows in your table, just enough to demonstyrate the problem

on second thought, please do this in the mysql forum (forum436) because this is the forum for ANSI SQL

r937.com | rudy.ca
 
Sorry, I was not paying attention. Thank you will post in the other forum :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top