Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL Select Single Character Words in Name Query

Posted on 2013-01-24
7
Medium Priority
?
437 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 1000 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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
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 1000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

963 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