Solved

SQL Select Single Character Words in Name Query

Posted on 2013-01-24
7
421 Views
Last Modified: 2013-01-29
I'm trying to run a SELECT query to find a list of names with any single character delimited by spaces in part of the field. Running the query with these names

Foo Bar
Lorem Ipsum
Chester A Arthur
FDR
Type S Car
Billy C Williams

Open in new window


would return

Chester A Arthur
Type S Car
Billy C Williams

Open in new window


I'm having trouble finding what the WHERE would be in this query.
0
Comment
Question by:vacpartswarehouse
7 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 38814972
it could be like this:
select * from yourtable
where yourfield like '% [a-z,A-Z] %'
or
select * from yourtable
where yourfield like '% ? %'
but you need to clarify your database engine/version.
0
 
LVL 3

Accepted Solution

by:
Nalinkumarbalaji earned 250 total points
ID: 38815027
Try the below one.

This is for displaying the Name with 1 word
SELECT * FROM NameList WHERE LEN(Name)=1

Your requested result.
SELECT * FROM Names WHERE Name like '% _ %'
0
 
LVL 32

Expert Comment

by:awking00
ID: 38815563
What dbms are you using (sqlserver, Oracle, ms access, etc.)?
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 32

Expert Comment

by:awking00
ID: 38827330
There are many ways to accomplish this but, without knowing what database you are using, we would only be guessing at a solution for you.
0
 

Author Comment

by:vacpartswarehouse
ID: 38831680
Sorry about that. The database is TSQL.
0
 
LVL 32

Assisted Solution

by:awking00
awking00 earned 250 total points
ID: 38831968
The the suggestion of WHERE Name like '% _ %' that has already been made above should work fine.
0
 

Author Closing Comment

by:vacpartswarehouse
ID: 38832124
Thank you!
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

830 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