Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Help with forming a query !!!
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Sagar Vikani  
View profile  
 More options Nov 1 2012, 6:17 pm
From: Sagar Vikani <sagarvikani2...@gmail.com>
Date: Thu, 1 Nov 2012 15:17:17 -0700 (PDT)
Local: Thurs, Nov 1 2012 6:17 pm
Subject: Help with forming a query !!!

I have a SQL query which looks like this :

SELECT code_ver, result FROM mastertest WHERE code_ver NOT LIKE '%DevBld%'
AND date >= DATE_SUB( (CURDATE()) , INTERVAL 90 DAY) ORDER BY date DESC;

This query gives me results from the last 90 days. Now I want to paginate
my results such that each page displays only rows from the last 10 days.

Can someone build a query which I can use with the 'will_paginate' ?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lee Irving  
View profile  
 More options Nov 9 2012, 6:08 am
From: Lee Irving <irvin...@gmail.com>
Date: Fri, 9 Nov 2012 11:08:53 +0000
Local: Fri, Nov 9 2012 6:08 am
Subject: Re: Help with forming a query !!!
If mastertest is a model

Mastertest.select("code_ver, result").
where("code_ver NOT LIKE '%DevBld%'").
where("date >= DATE_SUB( (CURDATE()) , INTERVAL 90 DAY)").
order("date DESC")

You can then call the .paginate on this:

Not sure what you mean by "ow I want to paginate my

> results such that each page displays only rows from the last 10 days"

If you meant you want to only select the records then add another .where()


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jack Royal-Gordon  
View profile  
 More options Nov 9 2012, 4:02 pm
From: Jack Royal-Gordon <jac...@pobox.com>
Date: Fri, 9 Nov 2012 13:02:05 -0800
Local: Fri, Nov 9 2012 4:02 pm
Subject: Re: Help with forming a query !!!
If I understand what you are trying to do, you want the first page to show results from the last 10 days, the next page to show results from the previous 10 days, etc.  If each day only has one result (or every page has the same number of results), then just add ':per_page => 10 (or whatever number of records you want on each page)' to the #paginate call to tell paginate to return results for 10 days.  If each day has a variable number of results, will_paginate is not well-suited to what you are trying to do.  Will_paginate is oriented towards partitioning your results into groups of 'n' and efficiently  moving among groups.  If you still want to use will_paginate, change your query to produce one record per day, set :per_page => 10, and find a way in your view to expand each day into all of it's results.

On Nov 9, 2012, at 3:08 AM, Lee Irving <irvin...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic