Solved

search words like

Posted on 2014-10-11
6
99 Views
Last Modified: 2014-10-20
Hello,
I would like to search for
1) words that start with a specific letter/s. For example, if I have record "William" and another "Howard" then I would like only to get William when I search for "w".
2) I have names of people and I would not like to search for the last name.
For example: If I have a record: John Howard and search for 'H' I would not get result, but I would get result if the name were Howard John. The same goes if the person has three names like Ann Pauline James. I would get result if I look for 'P' but not if I look for 'J'.
Can you please help me with this?
Greetings,
0
Comment
Question by:johnson1
6 Comments
 
LVL 34

Expert Comment

by:Michael-Best
ID: 40374872
Depending on the search engine that you use, can usually define your search by entering the key words  like this :  " ???? " in advanced search options.
Post your search engine for further feedback.
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 40374891
Please tell us the table schema of what you are searching, and specifically if the first name-last name are in separate columns, or the same columns, or the same column with a bunch of other text.
0
 

Author Comment

by:johnson1
ID: 40375074
I am using sql 2008. The first-last name is in one column (can also be first-middlename-lastname).
In this column there is only the name.

The columns in the table would be like this:   PersonId (int), Fullname(varchar(100)).  Tablename: Person.
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

Author Comment

by:johnson1
ID: 40375075
Sorry I meant MS SQL 2012.
0
 
LVL 65

Assisted Solution

by:Jim Horn
Jim Horn earned 250 total points
ID: 40375081
>The first-last name is in one column (can also be first-middlename-lastname).

1)  WHERE LEFT(the_name_column, 1) = 'W' will return any value that begins with a W, and w too assuming the column's collation is set to case insensitive.

2) I don't believe you're going to pull that off, as that ass-u-me's that any middle name is what we consider a middle name.  Jean Claude Van Damme?  The Claude is the middle name, Van is part of the last name, and not the middle name, so good luck with that. Rip Van Winkie?  Geordi La Forge?  Charo?  If you can state with certainty the logic here, spell it out for us, otherwise good luck.
0
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 250 total points
ID: 40377351
If you're matching only on the leading letter(s) in the first name, you can do this:

--and search for 'H'
WHERE
    Fullname LIKE 'H%'
--better than using a function, such as "LEFT", on the column


The middle name(s) issue is a bit trickier, because we have to make some assumptions.  How about these rules?  An entry with:
a) 1 word only, will be considered a first name;
b) 2 words only, will be considered first and last name;
c) 3+ words: the first will be considered first name, the second the middle name, and the third+ the last name;
would those rule work for you?
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question