0

I'm trying to list 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*"
1
  • Why not try it out and see what happens? Commented Aug 22, 2022 at 8:20

3 Answers 3

4
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.

Sign up to request clarification or add additional context in comments.

Comments

0

i would try:

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

Comments

-1

For getting list starting with eg: "D":

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

4 Comments

Please share more details. Why do you need concat in the WHERE clause?
in case of 'first name' value is null. script use the 'name' value from last name. Then it will list name start with 'D'
Please add all clarification to your answer by editing it. What makes you think that any value is NULL?
I removed all of my assumptions @NicoHaase . Now I write it as normal way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.