Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

paging on a select statement 1

Status
Not open for further replies.

JCrou82

Programmer
Aug 23, 2002
265
US
I have a table with first name, last name.

I want to be able to only select the records where the last names start from a-f. I attempted to use regexp but i don't think i was using right since nothing came up. does anyone know how to do that?

Select * from tblNames where lname regexp "^[a-f]";

what am i doing wrong? also, once I can actually get some input, how can i split this into pages? so that i only show 5 records per page?

Thanks
 
Code:
Select * from tblNames 
where substring(lname from 1 for 1) between 'a' and 'f'
order by lname 
limit 0,5

The limit clause will restrict the number of rows. To get the next five, use

Code:
Select * from tblNames 
where substring(lname from 1 for 1) between 'a' and 'f'
order by lname 
limit 5,5

I don't know why your original query does not work. In earlien versions (<3.23 or somewhere) regexp was case sensistive so it may be that?
 
thanks swampboogie. that'll do the trick. the rest is childsplay. btw, all of a sudden regexp seems to work. Go figure? i think there was an issue with phpmyadmin. oh well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top