5000 records is chump-change.

select *
from products
where product_name is not null
  and product name != ''
order by product_id

On a 5000-record set, this should be screaming fast even with no index
UNLESS your server is already drastically overloaded.

On Thu, December 13, 2007 9:14 am, tedd wrote:
> At 12:20 PM +0100 12/13/07, Zoltán Németh wrote:
>>2007. 12. 12, szerda keltezéssel 20.13-kor tedd ezt írta:
>>  > I would like to create a temporary table to perform searches.
>>>
>>>   From my main table, I need to exclude records that have certain
>>>  fields that are null or empty; and then sort the final result.
>>
>>why do you need a temp table for that?
>>select * from blah where not isnull(checkfield) and checkfield <> ''
>>order by someotherfield
>
> Zoltán:
>
> Ok, here's the problem.
>
> I have a table with over 5000 records.
>
> There is no index (not my dB) and the records are not complete.
>
> There is a numeric product_id field, but in the dB this is not in
> sequence.
>
> Some records have a product_id, but no product_name.
>
> I need to travel the dB showing each item in
> order (product _id) and excluding those products
> that have no product_name.
>
> That sounds simple enough, but currently for each
> step the entire table gets sorted (unless I'm
> doing it wrong).
>
> I was thinking that I could:
>
> 1. Create a temporary table.
> 2. Sort the table once.
> 3. Remove the records that have no product_name
> 4. And then just travel the temporary table for the duration of the
> script.
> 5. Drop the table when done with it.
>
> Now, what's wrong with my thinking?
>
> Cheers,
>
> tedd
>
>
>
>
>
>
> --
> -------
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to