yjim Posted August 21, 2009 Share Posted August 21, 2009 how can i issue a mysql search where the first letter of my item is A or B etc.. or if it starts with a number? Quote Link to comment https://forums.phpfreaks.com/topic/171351-solved-mysql-searching/ Share on other sites More sharing options...
Aravinthan Posted August 21, 2009 Share Posted August 21, 2009 Wrong forums... But you can use LIKE command Quote Link to comment https://forums.phpfreaks.com/topic/171351-solved-mysql-searching/#findComment-903647 Share on other sites More sharing options...
yjim Posted August 21, 2009 Author Share Posted August 21, 2009 ok i have this code SELECT * FROM media_cat WHERE name LIKE '(0-9)%' ORDER BY name ASC its not working. im trying to get all the results that start with a number value. Quote Link to comment https://forums.phpfreaks.com/topic/171351-solved-mysql-searching/#findComment-903649 Share on other sites More sharing options...
Aravinthan Posted August 21, 2009 Share Posted August 21, 2009 Try: SELECT * FROM media_cat WHERE name LIKE [0-9]%' ORDER BY name ASC Should work... Quote Link to comment https://forums.phpfreaks.com/topic/171351-solved-mysql-searching/#findComment-903650 Share on other sites More sharing options...
sdi126 Posted August 21, 2009 Share Posted August 21, 2009 SELECT * FROM media_cat WHERE substring(name,1,1) in(0,1,2,3,4,5,6,7,8,9) ORDER BY name ASC Quote Link to comment https://forums.phpfreaks.com/topic/171351-solved-mysql-searching/#findComment-903655 Share on other sites More sharing options...
Aravinthan Posted August 21, 2009 Share Posted August 21, 2009 I made a typo, It should be: SELECT * FROM media_cat WHERE name LIKE '[0-9]%' ORDER BY name ASC Quote Link to comment https://forums.phpfreaks.com/topic/171351-solved-mysql-searching/#findComment-903657 Share on other sites More sharing options...
yjim Posted August 21, 2009 Author Share Posted August 21, 2009 neither works..i have several items that start with integers 0-9 also. Quote Link to comment https://forums.phpfreaks.com/topic/171351-solved-mysql-searching/#findComment-903671 Share on other sites More sharing options...
Aravinthan Posted August 21, 2009 Share Posted August 21, 2009 Are you sure? I tried it and it works fine for me... What is the error you get? Quote Link to comment https://forums.phpfreaks.com/topic/171351-solved-mysql-searching/#findComment-903673 Share on other sites More sharing options...
yjim Posted August 21, 2009 Author Share Posted August 21, 2009 empty results Quote Link to comment https://forums.phpfreaks.com/topic/171351-solved-mysql-searching/#findComment-903675 Share on other sites More sharing options...
Aravinthan Posted August 21, 2009 Share Posted August 21, 2009 Run this: SELECT * FROM media_cat WHERE name LIKE '0%' ORDER BY name ASC And tell me if gives a result Quote Link to comment https://forums.phpfreaks.com/topic/171351-solved-mysql-searching/#findComment-903676 Share on other sites More sharing options...
yjim Posted August 21, 2009 Author Share Posted August 21, 2009 that works for the rows that start with 0 digits, but i also have rows that start with other numbers that arent being displayed. Quote Link to comment https://forums.phpfreaks.com/topic/171351-solved-mysql-searching/#findComment-903679 Share on other sites More sharing options...
yjim Posted August 21, 2009 Author Share Posted August 21, 2009 fixed, thanks. mysql_query("SELECT * FROM `media_cat` WHERE substring(name,1,1) RLIKE '[0-9]'"); Quote Link to comment https://forums.phpfreaks.com/topic/171351-solved-mysql-searching/#findComment-903686 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.