473,395 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

phone book lookup query

Hi,
Can you recommend the best way (fast and most productive) to search an
employees table?

Let's say I have a table that has this kind of structure:
firstname, lastname, state, city, street, phonenumber,
socialsecuritynumber, dateofbirth, etc.

I'd like to provide a search window with one text entry field, that
the text entered will be searched at all fields, and even in more then
one field toghether (like if you enter "david z" it will search for
like '%david%' in first name and like '%z%' in last name).

the problem is I can't write the query that'll perform fast but search
all of these fields, plus there's no way to use an index when using
LIKE.

I can't loose the functionality described above (I'm not the client,
and not the project manager) but I am trying to find an efficient
solution to the problem.

Since most systems has some sort of directory table (like authors in
pubs) you would think it will be a classic problem, but I found no
recommendations on how to approach it.

any help will be most appreiciated.
Jul 20 '05 #1
2 1528
-P-
"Shoval Tomer" <sh****@softov.co.il> wrote in message news:71**************************@posting.google.c om...
Hi,
Can you recommend the best way (fast and most productive) to search an
employees table?

Let's say I have a table that has this kind of structure:
firstname, lastname, state, city, street, phonenumber,
socialsecuritynumber, dateofbirth, etc.

I'd like to provide a search window with one text entry field, that
the text entered will be searched at all fields, and even in more then
one field toghether (like if you enter "david z" it will search for
like '%david%' in first name and like '%z%' in last name).
the problem is I can't write the query that'll perform fast but search
all of these fields, plus there's no way to use an index when using
LIKE.


That's implying a "CONTAINS" - are you sure you don't want "STARTS WITH"?

"and first_name like 'david%'
and last_name like 'z%' "

will use an available index on first or last name. If you're obligated to use "contains", then you're correct - the
optimizer won't use an index for those.

--
Paul Horan
Sr. Architect
VCI Springfield, MA
www.vcisolutions.com
Jul 20 '05 #2
Shoval Tomer (sh****@softov.co.il) writes:
Can you recommend the best way (fast and most productive) to search an
employees table?

Let's say I have a table that has this kind of structure:
firstname, lastname, state, city, street, phonenumber,
socialsecuritynumber, dateofbirth, etc.

I'd like to provide a search window with one text entry field, that
the text entered will be searched at all fields, and even in more then
one field toghether (like if you enter "david z" it will search for
like '%david%' in first name and like '%z%' in last name).

the problem is I can't write the query that'll perform fast but search
all of these fields, plus there's no way to use an index when using
LIKE.

I can't loose the functionality described above (I'm not the client,
and not the project manager) but I am trying to find an efficient
solution to the problem.

Since most systems has some sort of directory table (like authors in
pubs) you would think it will be a classic problem, but I found no
recommendations on how to approach it.


I have a longer discussion on http://www.sommarskog.se/dyn-search.html.

As for LIKE, you may consider adding clues that the user can add:
"Starts with", "contains". In that way you can control whether the leading
% has to be there. This is probably also good for usability, since
it can help the user to cut down the number of hits.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: William Morris | last post by:
Our application tracks contact information. One of our clients, a car dealership, has asked about being able to enter a lastname and phone number and getting as much of the main form filled out as...
3
by: my-wings | last post by:
I've been reading about how evil Lookup fields in tables are, but I've got to be missing something really basic. I know this subject has been covered before, because I've just spent an hour or two...
3
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems...
2
by: Mike Turco | last post by:
I'm creating a fairly phone book for an organization (maybe 400 pages). Members are listed out by chapter with their phone number and all that. There is also to be an index by last name. In...
1
by: Robert | last post by:
I am trying to create a db for service providers by county. I'm relatively new to db programming, but I have done quite a bit of programming ranging from the old basic days up to doing some...
2
by: Greg Strong | last post by:
Hello All, Is it possible to change table field lookup properties in code? I've been able to change other field properties in code, however so far no luck with field lookup properties. What...
3
by: Radu | last post by:
Hi. I have the following problem - I need to build a user-control in asp.net (an ascx) to somehow allow the users to search by first name or last name among a big (~10.000 records) email addresses...
10
by: Mike Miller | last post by:
Hi, Am wanting to send email with php and need to access the global outlook address book. Are there any examples/tutorials on how to do this? M
1
by: joeino | last post by:
I want to do a lookup query and append the record to a history table before editing the data. I created a macro to run the lookup query to append the record to history and it works fine. I did the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.