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. Quote 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%' Quote 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 Quote 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 Quote 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 Quote 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]' Quote 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]' Quote Link to comment https://forums.phpfreaks.com/topic/253936-where-clause-first-letter/#findComment-1309179 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.