Solved

SQL Select Single Character Words in Name Query

Posted on 2013-01-24
7
432 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
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…

630 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