Solved

SQL Select Single Character Words in Name Query

Posted on 2013-01-24
7
387 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 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
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
Comment Utility
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 31

Expert Comment

by:awking00
Comment Utility
What dbms are you using (sqlserver, Oracle, ms access, etc.)?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 31

Expert Comment

by:awking00
Comment Utility
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
Comment Utility
Sorry about that. The database is TSQL.
0
 
LVL 31

Assisted Solution

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

Author Closing Comment

by:vacpartswarehouse
Comment Utility
Thank you!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In today’s complex data management environments, it is not unusual for UNIX servers to be dedicated to a particular department, purpose, or database.  As a result, a SAS® data analyst often works with multiple servers, each with its own data storage…
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now