2 messages in com.mysql.lists.mysqlRe: HELP! mysql returns 'empty set' w...
FromSent OnAttachments
jeff gage15 Dec 1999 16:55 
Matthew Vanecek15 Dec 1999 16:57 
Subject:Re: HELP! mysql returns 'empty set' when data exists - why ?
From:Matthew Vanecek (mev0@unt.edu)
Date:12/15/1999 04:57:38 PM
List:com.mysql.lists.mysql

jeff gage wrote:

Hello mysql 'ers

I am trying an ambitious project w/ 1.2 million records, but I am having a problem.

when requesting:

select title from directory where dir1 = 'Sports';

The column I select from keeps returning 'empty set' eventhough I know the record exists. I have verified it using a table w/ identical composition, which only has one line, but merily returns the data.

There are some confounding factors w/ the large table of 1.2 M records.

a) I have created an index on the colomn (dir1) which is a varchar(20).

b) If I use " select title from directory where dir1 like '%Sports%' "

I get the results, but if you use like with wildcards, mysql dosent use the index, so you have to wait a long time. Also that would be such an ugly kludge of a solution that I could not look at myself in the mirror anymore.

I am thinking that perhaps, there is a NULL field in the column that causes an error, or it has something to do with the default data type in the column. When I use 'describe table', it shows that dir1 has a key value of 'MUL' and a defaut value of nothing. I changed the default value to '0' and still the query against dir1 produces an empty set. The column is set to not null.

Has anyone had this kind problem before ?

I am all ears for any help.

Try doing a "SELECT * FROM table" and view the data, maybe after dumping it to an outfile. The first assumption would be that there are no values of dir1 which exactly equal "Sports". This is almost a certainty, because of the fact that you aren't getting any results.

Just as a "just in case" solution, do a "like '%Sports%'" query and see what's in there. Then do something like an "UPDATE dir1 SET dir1='Sports' WHERE whatever". Then try your original query again.

HTH,