» Home » Records » Page 1
Excluding certain records from a Django queryset as long as those records are not the first or last X records
by clubbedseal in Web Design

I have a Django recordset (mysource) holding temperature reading for each day (for_date). When the last 40 days readings are available for me, for example, I want to display only 20 days on a graph. To accomplish this, I do the following:


for day_num in range (1, 32):
if day_num % 2 == 1: # remove every 2nd day
mysource = mysource.exclude(for_date__day=day_num)

How can you check for foreign key references for a list of records before attempting to delete any of these records in MySQL?
by LukeG in Databases

Is there a way, when you have a list of records, to check if each of these records have foreign key references before you attempt to delete any of these records?


As an example, if I have a list of borrowers and a list of books, you should not be able to delete a borrower from the system if he still has books on loan. (My actual system is much more complicated than that however - a l


Custom Paging in Sql ,to display 10 records in Repeater ,and the records change with the submit button
by Chris in Programming Languages

There are 4 table


Table 1---->QuestionMaster(Field is-->Id,Question).
Table 2---->SurveyMaster(Field is---->Id,Name)
Table 3---->SurveyQuestionMap(Field is--->Id,SurveyId,QuestionId)
Table 4---->SurveyRateMap(Field is--->Id ,SurveyId, RatingTypeId)

The Stored Procedure is


ALTER Procedure [dbo].[GetQuestio

Already save has_many relation in getCMSField_forpopup records in appearing again in every new records in SilverStripe
by waggy in Programming Languages

I have one getCMSField_forpopup form for an event. I made another popup inside that to give multiple dates to that event(using has_many relation). When I give date 2 different dates/times to event "A" and then after saving event "A", I open main getCMSField_forpopup to enter details of another event "B" then I see dates/times (complextablefield) already there which were actually meant to appear


Records Access is very slow in rails with mysql havin table records 80K+
by dcutting in Databases

I have a model named website which is having 80K+ records. I am getting those records through
kaminari pagination in index page.


Here is the code for getting the list in index


@q = current_user.organization.websites.where('website !=""').group('website').search(params[:q])
@websites = @q.result.page(params[:page]).per(50)

My Problem her


Removing duplicate records based on three cols but keeping the records with the highes value in a forth col
by boobytrapped in Databases

I've read alot of the questions on dealing with duplicates and they have helped me write the SQL I do have, but my quest is to remove the duplicates not based on the duplication fields, but on another field.


In my project I'm defining duplicates based on three cols being equal, but there is a forth col transaction date/time that will never* be duplicated. I want to keep the newest


MySQL select records where there are multiple matching records in related table
by vyazkov in Databases

I have 2 tables:


pages table contains field id


pages2categories table contains fields page and category


I want to select records from the pages table


where (there is a record in the pages2categories table
WHERE pages2categories::page = pages::id AND pages2categories:: category = 'X')
AND (ther

How do I Iterate through a small set of records and retrieve records that match criteria set in each record
by cashshadow in Databases

I have a table tblCriteria that contains a small (<20) set of records. Each record has a field of criteria.


I want SQL to move through these records when requested tblFilterRun, filter the main table tblRecords (~5000 records) and then insert some key fields from the matching records into another table tblFilterResults.



Find which pairs of records' positions can safely be switched in a combined set of records
by Matt Willtrout in Databases

Here is the situation: I have a page where I can edit multiple records at once (Let's say invoices). They are not shown below each other, but they are edited like one record. At page load, values are displayed in a given field only when they are the same throughout the whole set of records.


Now, on top of that, I also want to edit child records (1-n relationship; lines of invoice).


creating records in .each in lambda{} doesn't change a number of records in RSpec
by Mike in Programming Languages

I initially wrote testing code like the following;


fixtures :records
it "should double number of records " do
@payment_transactions = PaymentTransaction.find :all
length = @payment_transactions.length
lambda{
@payment_transactions.each{ |pt|
PaymentTransaction.create(:data => pt.data)
}
}.should change{PaymentTrans

Next
Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2014 © bighow.org All Rights Reserved .