karimali831 Posted December 28, 2011 Share Posted December 28, 2011 Hi, I am using while loop to fetch rows of users and want to add an A - Z search, if the user clicks "S" for example it should return all results where the first letter of string (whether upper case or not) is equal to "S" or "s". Can I do this with WHERE clause? Thanks anyone. Link to comment https://forums.phpfreaks.com/topic/253936-where-clause-first-letter/ Share on other sites More sharing options...
melloorr Posted December 28, 2011 Share Posted December 28, 2011 Hi, I am using while loop to fetch rows of users and want to add an A - Z search, if the user clicks "S" for example it should return all results where the first letter of string (whether upper case or not) is equal to "S" or "s". Can I do this with WHERE clause? Thanks anyone. WHERE whatever LIKE 's%' Link to comment https://forums.phpfreaks.com/topic/253936-where-clause-first-letter/#findComment-1301785 Share on other sites More sharing options...
karimali831 Posted December 28, 2011 Author Share Posted December 28, 2011 Thanks very much!! Brilliantly simple Link to comment https://forums.phpfreaks.com/topic/253936-where-clause-first-letter/#findComment-1301786 Share on other sites More sharing options...
karimali831 Posted January 5, 2012 Author Share Posted January 5, 2012 I have other question, want to do something simular - WHERE first letter is non-alphabet? So it can be anything such as WHERE = |?><!£$%^& etc Link to comment https://forums.phpfreaks.com/topic/253936-where-clause-first-letter/#findComment-1304452 Share on other sites More sharing options...
karimali831 Posted January 18, 2012 Author Share Posted January 18, 2012 bump Link to comment https://forums.phpfreaks.com/topic/253936-where-clause-first-letter/#findComment-1308830 Share on other sites More sharing options...
PFMaBiSmAd Posted January 18, 2012 Share Posted January 18, 2012 WHERE your_column REGEXP '^[^a-zA-Z]' Link to comment https://forums.phpfreaks.com/topic/253936-where-clause-first-letter/#findComment-1308835 Share on other sites More sharing options...
dreamwest Posted January 19, 2012 Share Posted January 19, 2012 WHERE `column` REGEXP '^[0-9]' Link to comment https://forums.phpfreaks.com/topic/253936-where-clause-first-letter/#findComment-1309179 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.