Solved

VB.net SQL Check if name is within a string

Posted on 2014-09-11
11
107 Views
Last Modified: 2014-09-11
Hi

I have VB.nrt code where I use the following SQL to check if a child's name is in a certain string. There is a child with the name "Nahil" but the following returns no match
Select Distinct [CustomerID], [BANK_REF]  From [CHILDREN] Where CHARINDEX('ABSA BANK Nahil LaherNMA',[Child Name]) > 0
0
Comment
Question by:murbro
  • 6
  • 5
11 Comments
 
LVL 22

Expert Comment

by:plusone3055
ID: 40317423
my initial though is there should be a space somewhere for example
Nahil LaherNMA

should be
Nahil Laher NMA
0
 

Author Comment

by:murbro
ID: 40317444
Hi. That makes no difference unfortunately
0
 
LVL 22

Expert Comment

by:plusone3055
ID: 40317452
have you run it against another name where it does return a specific  result and if so please post that
 code
so we can dig deeper  :)
0
 

Author Comment

by:murbro
ID: 40317485
I used the following. There are ten children with the name "Jayden". Nothing came up

Select Distinct [CustomerID], [BANK_REF]  From [CHILDREN] Where CHARINDEX('I think Jayden was here',[Child Name]) > 0
0
 
LVL 22

Accepted Solution

by:
plusone3055 earned 500 total points
ID: 40317507
test this out

Select  [CustomerID], [BANK_REF]  From [CHILDREN] Where [Child Name] LIKE '%Jayden%'

if that works  and brings back the 10

try
Select  Distinct [CustomerID], [BANK_REF]  From [CHILDREN] Where [Child Name] = 'Nahil'
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:murbro
ID: 40317547
I tried Select Distinct [CustomerID], [BANK_REF] From [CHILDREN] Where [Child Name] = 'Jayden' and it brought back the ten
0
 
LVL 22

Expert Comment

by:plusone3055
ID: 40317569
Then use

Select  Distinct [CustomerID], [BANK_REF]  From [CHILDREN] Where [Child Name] = 'Nahil'
0
 

Author Comment

by:murbro
ID: 40317577
The whole point of my question is finding a string within a longer string
0
 

Author Closing Comment

by:murbro
ID: 40317592
This LIKE function actually does the job well. Sorry about the confusion
0
 
LVL 22

Expert Comment

by:plusone3055
ID: 40317620
I thought it would.. No worries
Have a great day :)
0
 

Author Comment

by:murbro
ID: 40317694
Thanks again. Have a great day too
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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