Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selecting records from a particular letter onwards

Tags:

sql

sql-server

Taking in consideration a table tbl_users, I want to get a list of all users start from a certain letter and all the subsequent letters. For example, if I choose the letter 'C' it will display all users starting with 'C' and all the successive letters (i.e. 'D', 'E', etc.). How is it done?

like image 574
chris05 Avatar asked Dec 30 '25 01:12

chris05


2 Answers

Just use this WHERE clause:

WHER username >= 'C'
like image 52
Lasse V. Karlsen Avatar answered Dec 31 '25 16:12

Lasse V. Karlsen


I did not test this, but I would think something like this:

SELECT *
FROM tbl_users
WHERE SUBSTRING(tbl_users.UserName, 0, 1) >= 'C'
like image 36
ericosg Avatar answered Dec 31 '25 16:12

ericosg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!