开发者

mysql - select concat query

I'm trying to list 开发者_Go百科all users beginning with a letter, e.g. D

Would the following be the right method of doing this.

Select concat(firstname, '',lastname) from users where concat(lastname) = "D*"


SELECT concat(firstname, '',lastname) FROM users WHERE lastname LIKE "D%"

If you want to use wildcards, you need the LIKE operator. Also, in your where clause you only have one column (lastname), so you don't need concat.


i would try:

select * from users where lastname like 'D%';


For getting list starting with eg: "D":

SELECT firstname FROM users WHERE LEFT(firstname,1)= 'D';
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜