简体   繁体   中英

How to select all rows WHERE a string filed start with a specific string

How can I do this: select all rows WHERE a string 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%'

请尝试以下操作:

SELECT * FROM mytable WHERE user_id LIKE 'asd%'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM