PDA

View Full Version : select problem


ynotlim
09-29-2006, 10:49 PM
Hello...

I have a DB with 50,000 entries. I have a search form to search through the DB. If the recno=30123456 and you search the recno, you get that one file. what if i want a query that searches alll recno's that contain 30?? Can I do that using mysql or do I need to program that in my java app??

Thank you

Tony

kreoton
09-29-2006, 11:52 PM
Whis example would help you ;)
SELECT * FROM table WHERE recno LIKE '30%'

guelphdad
09-30-2006, 01:38 AM
can they contain 30 anywhere in the value? if so use the example above. If you only want ones that start with 30 use columname like '30%'

the difference is if you are looking from the beginning of the string your query will use an index. when your query starts with % will not use an index and will be significantly longer.

ynotlim
09-30-2006, 01:53 AM
thank you !! I really appreciate your help =)