for DBase you probably need to store everything as upper or lowercase
Main Topics
Browse All TopicsI'm writing a query in Delphi using a DBase IV table. I have an index on a field called title, and I want to search for all records that begin with the title that I enter.
ex.
select * From Tablename Where Title like "example%"
This query works but doesn't take use of the index, my table is very large so you'll wait about 30 seconds until you get a response. My solution to this was to use a between statement
ex
'Select * From Tablename Where TITLE BETWEEN "example" AND "exampleZZZZZZZZZZZZZZZZZZ
this takes proper use of my query and runs much quicker. My 1st question is, is should I be using 'Z' or another char to add onto my string what is the char with the greatest value?
My second question is I want to ignore the case of the original word so whether example is spelled Example EXAMPLE or ExAMple you still get all the records that start with example no matter the case. How can I do this efficiently, I tried to use the upper function in my query (to always compare against the same case) and it basically froze my program it took so long. Any ideas on if this is possible or if I should just store all of the values in my table as uppercase?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
2.
>>I tried to use the upper function in my query (to always compare against the same case) and it basically froze my >>program it took so long.
The better approch to insert data into a table is
Before insert the table, make the data in which format you need to display to the customer.
for eg: if you are storing the surname as captial , at the time of insert itself store it to cpital. Because inserting/editing happening rarely most of the time, but querying data will happen several times.
Now When you use uppercase function, before fulshin gout the data, the DB will make a temp table(something like that) to convert the uppercase funcation. It has to go through each field in the table and convert the record to uppercase. So it takes time. Try to get the right data into the database at the user level or set the field to uppercase.
1.
>> select * From Tablename Where Title like "example%"
* also make the query a little slower atleast on the client side.
if you don't need all the fields in the query, Instead of * , put the field names requried for the query. it will improve performace.
There is Table1.IndexName = 'TABLE 1INDEX1' some thing like that. Usually query will automatically take care of Indexs.
Also check the hardware side of server and client, is it capable to handle?
IF using Network, how is the speed?
Consider all these.
I thing i pour a little extra
Hope this helps you
sun4sunday
Hi,
Let suppose that your field is 50 chars in length. You are passing a string ('example' in your case) as a search string in a variable str. Try something like:
var
str: string;
i: integer;
tempstr: string;
begin
str := 'example';
...
Query1.SQL.Clear;
Query1.SQL.Add('SELECT * FROM Tablename Where TITLE BETWEEN ' + QuotedStr(str));
tempstr := str;
for i := Length(str) + 1 to 50 do tempstr := tempstr + #255;
Query1.SQL.Add('AND ' + QuotedStr(tempstr));
Query1.Open;
Regards, Geo
Business Accounts
Answer for Membership
by: BlackTigerXPosted on 2006-08-10 at 09:09:22ID: 17288939
use greater than and less than
where title > 'example' and title < 'exampleZ'
something like that