Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 439
  • Last Modified:

SQL Select Single Character Words in Name Query

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
vacpartswarehouse
Asked:
vacpartswarehouse
2 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
 
NalinkumarbalajiCommented:
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
 
awking00Commented:
What dbms are you using (sqlserver, Oracle, ms access, etc.)?
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
awking00Commented:
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
 
vacpartswarehouseAuthor Commented:
Sorry about that. The database is TSQL.
0
 
awking00Commented:
The the suggestion of WHERE Name like '% _ %' that has already been made above should work fine.
0
 
vacpartswarehouseAuthor Commented:
Thank you!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now