Re: A bit of SQL help and logic correction, perhaps
Re: A bit of SQL help and logic correction, perhaps
- Subject: Re: A bit of SQL help and logic correction, perhaps
- From: Reid Bundonis <email@hidden>
- Date: 10 Jan 03 17:35:06 -0500
Reply to: Re: A bit of SQL help and logic correction, perhaps
Honestly... because I have no idea how to structure a random select using a qualifier statement. For me it was easier to use sql.
Ok, maybe that was too honest.
R-
Brent Shank wrote:
>First question: Why are you using raw SQL rather than EOQualifier and >EOSortOrderings?
>
>Brent
>
>On Thursday, January 9, 2003, at 05:53 PM, Reid Bundonis wrote:
>
>> Ok, I have a table (LETTER) that contains three columns, NAME, >> SUBJECT, IS_HIGHLIGHTED. The column, IS_HIGHLIGHTED is a boolean, and >> is set to 1 if true, otherwise I leave it null. The application >> started rather simple. As main loaded, I would fetch a random set of >> results and display them in a repetition using a Fetch Specification's >> raw expression, for example:
>>
>> SELECT * FROM LETTER WHERE IS_HIGHLIGHTED = 1 ORDER BY RAND() LIMIT 5;
>>
>> However, now I need to be able to select all of the IS_HIGHLIGHTED = 1 >> (true) records, and a random set of not highlighted records limited to >> 5. The highlighted records must come at the top of the results, and >> the non highlighted records come beneath it.
>>
>> Logically, I keep telling myself that this is two trips to the >> database in two distinct selects since the results are really two >> different sets. However, I figured I would throw out the question to >> the group to see if there is a solution. I tried to place the order >> by only on the IS_HIGHLIGHTED IS NULL part like:
>>
>> SELECT * FROM LETTER WHERE (IS_HIGHLIGHTED = 1) OR (IS_HIGHLIGHTED IS >> NULL ORDER BY RAND() LIMIT 5);
>>
>> Obviously, it was not happy. I am guessing that I need to do this as >> two fetches. I guess I am looking for a simple way out.
>>
>> Thanks for your help.
>> _______________________________________________
>> webobjects-dev mailing list | email@hidden
>> Help/Unsubscribe/Archives: >> http://www.lists.apple.com/mailman/listinfo/webobjects-dev
>> Do not post admin requests to the list. They will be ignored.
>
>
>
>RFC822 header
>-----------------------------------
>
> RECEIVED: from SF_Database by POP_Mailbox_-1169914335 ; 10 JAN 03 14:16:01 UT
> Received: from SMTPOUT.MAC.COM by mail.imc-nj.com
> with SMTP (QuickMail Pro Server for MacOS 1.1.2); 10-Jan-2003 >14:15:52 -0500
> Received: from asmtp01.mac.com (asmtp01-qfe3 [10.13.10.65])
> by smtpout.mac.com (Xserve/MantshX 2.0) with ESMTP id h0AJFnD5005819
> for <email@hidden>; Fri, 10 Jan 2003 11:15:50 -0800 (PST)
> Received: from mac.com ([17.203.34.51]) by asmtp01.mac.com
> (Netscape Messaging Server 4.15) with ESMTP id H8IIUC00.9A0;
> Fri, 10 Jan 2003 11:15:48 -0800 > Date: Fri, 10 Jan 2003 11:15:48 -0800
> Subject: Re: A bit of SQL help and logic correction, perhaps
> Content-Type: text/plain; charset=US-ASCII; format=flowed
> Mime-Version: 1.0 (Apple Message framework v551)
> Cc: "webobjects-dev" <email@hidden>
> To: Reid Bundonis <email@hidden>
> From: Brent Shank <email@hidden>
> In-Reply-To: <email@hidden>
> Message-Id: <email@hidden>
> Content-Transfer-Encoding: 7bit
> X-Mailer: Apple Mail (2.551)
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.