dreamwest Posted June 3, 2009 Share Posted June 3, 2009 Im trying to select rows base on a letter a. So i need to select all rows starting with the letter a id | column 1 | apple 2 | bannana 3 | orange etc So i need a query that will only select id 1 which starts with the letter a This searches for a in the whole string $search = "a"; $sql = "SELECT * FROM tags where (tag like '%".$search."%') order by tag DESC limit 10"; Quote Link to comment https://forums.phpfreaks.com/topic/160736-solved-select-beginning/ Share on other sites More sharing options...
Ken2k7 Posted June 3, 2009 Share Posted June 3, 2009 <?php $search = 'a'; $sql = 'SELECT * FROM tags WHERE tag LIKE "' . $search '%" ORDER BY tag DESC LIMIT 10'; Quote Link to comment https://forums.phpfreaks.com/topic/160736-solved-select-beginning/#findComment-848308 Share on other sites More sharing options...
dreamwest Posted June 3, 2009 Author Share Posted June 3, 2009 Just had to change wildcard to right side of query $search = "a"; $sql = "SELECT * FROM tags where (tag like '".$search."%') order by tag DESC limit 10"; Quote Link to comment https://forums.phpfreaks.com/topic/160736-solved-select-beginning/#findComment-848309 Share on other sites More sharing options...
dreamwest Posted June 3, 2009 Author Share Posted June 3, 2009 <?php $search = 'a'; $sql = 'SELECT * FROM tags WHERE tag LIKE "' . $search '%" ORDER BY tag DESC LIMIT 10'; Thanks. I worked it out as u posted Quote Link to comment https://forums.phpfreaks.com/topic/160736-solved-select-beginning/#findComment-848310 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.