Page 1 of 1

How to retrive numbers from database

Posted: Tue Jul 27, 2010 6:36 am
by zuby
Guys this I presume is simple but I cant get it to work for some reasons.
I want to write a query that will retrieve numbers from my table. I have retailers with first letters as numbers (0-9). My query only retrieves letters and not numbers..any help pls??

Code: Select all

function get_letter($letter){
   $conn = db_connect();
   $query = "select * from retailer where name LIKE '$letter%' GROUP BY name";
   $result = @$conn->query($query);
}

Re: How to retrive numbers from database

Posted: Tue Jul 27, 2010 7:57 am
by zuby
Thank you manzar but my intention is not to count how many rows affected but to fetch all records that their first letters are number ranging from 0-9..e.g 999 inks

Re: How to retrive numbers from database

Posted: Tue Jul 27, 2010 8:26 am
by Benjamin

Code: Select all

select * from retailer where name REGEXP '^[0-9].*' GROUP BY name

Re: How to retrive numbers from database

Posted: Wed Jul 28, 2010 3:21 am
by Mordred
And since you've already made the mistake of posting this in "Security", you might as well read up on mysql_real_escape_string() :)

Re: How to retrive numbers from database

Posted: Wed Jul 28, 2010 7:08 am
by zuby
@benjamin, thanks for the reply but I stil cant get it to work. pls if you have time could u please visit my site then click on (0-9) under browse retailers.
http://connektor.co.uk/vouchers/

Thanks