Reputation: 417
I am currently making a program in c# that uses SQL queries. I am new to SQL and would like some help on a matter.
Is it possible for a specific position in a string to be queried?
Eg. SELECT ID FROM Names WHERE Firstname[0] = "J" AND Lastname = "Doe"
If anything is unclear please let me know, any help is appreciated, thank you.
Upvotes: 0
Views: 63
Reputation: 1269563
Yes, you can, but rather like this
SELECT ID
FROM Names
WHERE Firstname LIKE 'J%' AND Lastname = 'Doe';
Notes:
LIKE
operation has a pattern. The pattern says the first character is J; %
is a wildcard that matches 0 or more characters.Upvotes: 1
Reputation: 31
You could use LIKE
in WHERE
clause.
example:-
SELECT ID FROM Names WHERE Firstname LIKE "J%" AND Lastname = "Doe"
Upvotes: 1
Reputation: 1
you can use keyword 'like' for example : WHERE names LIKE 'a%' it will return all name starting with character 'a'. like wise '%a'it will return all names ending with 'a'.
Upvotes: 0