How to select all rows WHERE a string filed start with a specific string
How can I do this: select all rows WHERE a str开发者_如何学Pythoning filed start with a specific string like this (it's a command for SqlDataAdapter
select command string in C#):
SELECT * FROM mytable WHERE user_id = asd*
asd means all user_id filed that start with asd
.
Use a LIKE statement such as:
SELECT * FROM mytable WHERE user_id LIKE 'asd%'
The % is a wild card, so that would work if you're looking for a string that starts with asd, otherwise, if you're just looking for asd anywhere in the string:
SELECT * FROM mytable WHERE user_id LIKE '%asd%'
Try the following:
SELECT * FROM mytable WHERE user_id LIKE 'asd%'
精彩评论