开发者

sql simple question help

I need to return all of the names o开发者_开发技巧f people that contain certain letters, or a combination of letters.

for example

names = bob, mary, nick

return names with the letter "b"

returns bob

return names with the letter "ar"

returns mary

so

SELECT name
FROM people
WHERE ???


WHERE name LIKE '%ar%'

for MS-Access, use

WHERE name LIKE '* ar *'
Ignore the spaces between * and 'ar'. See http://office.microsoft.com/en-us/access-help/like-operator-HP001032253.aspx


SELECT name 
FROM people 
WHERE name like '%ar%'

% is like "what ever"
you can use LIKE and % just for string fields


Use 'like' operator by using that you can do it


WHERE NAME LIKE '%<letter-or-string>%'


SELECT name 
FROM people 
WHERE name like '%ar%'  ----returns Mary

WHERE name like 'b%'    ----returns bob

WHERE name like  '%k'   ----returns nick

Note: Do not execute all the 'where' conditions together.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜