Start New Discussion Reply to this Discussion How to search a mysql database by the first letter an entry starts with
What I need to do is search brand names, find all the brands that start with the letters A-E and put those under a header on my webpage. Then search F-O and then P-Z and do the same thing. How would I go about querying the database to get the brands that start with A-E and so on? Ive got a products table with a brands row to help with the query.
Jfunch
Light Poster
27 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
There is a function called LEFT which can be used to grab the first letter of a field for comparison
example:
SELECT * FROM tblBrands WHERE LEFT(Brand,1) BETWEEN 'A' AND 'E'
etc...
Hearth
Posting Whiz
302 posts since Apr 2008
Reputation Points: 123
Solved Threads: 44
Skill Endorsements: 4
© 2013 DaniWeb® LLC
Page rendered in 0.0581 seconds
using 2.66MB