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';
精彩评论