How to retrieve the records those character star starting with A OR B OR C ,
I just tried this query
SELECT * FROM `test_tbl` WHERE Left(cus_name, 1) = 'a'
---> display all customer name starting with character a
AND I added one more condition, That is
SELECT * FROM `test_tbl` WHERE Left(cus_name, 1) = 'a' or Left(cus_name, 1) = 'b'
--->It displayed all customer name starting with character a and in some records middle i saw some name starting with b also,
What i want is , i want pull out records , which names are starting with A or B or C ,
And also it should order by alphabetical order,
Also i tried this below query.
SELECT * FROM `test_tbl` WHERE Left(cus_name, 1) REGEXP '^[^a-z]+$';
The rendered records for that above is , just two records started with A,
This above question for doing the alphabetical pagination ,
Thanks
You can try:
It will list all rows where
cus_namestarts with eithera,borc.The regex used is
^[abc]:^: Is the start anchor[abc]matches either anaor abor ac. It is equivalent to(a|b|c)The regex you were using :
^[^a-z]+$^is the start anchor.^inside the character classnegates it. So
[^abc]is anycharacter other than the three
listed.
+is the quantifier for one ormore.
$is the end anchor.So effectively you are saying: give me all the rows where
cus_namecontains one or more letters which cannot be any of the lowercase letters.