![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
oops. I inadvertently re-used "n", probably making things confusing. * I should have written: I'm doing a JOIN on 2 tables, where the relationship is n:1 USING ( Foo ), and want a well-defined subset of the total (LIMIT w OFFSET x ). * Since it's a JOIN, the LIMIT only returns w records whereas I want it to return w distinct Foos regardless of how many raw records the n:1 relationship requires. Is there a slicker way to do it than the brute-force way of getting DISTINCT Foo LIMIT w OFFSET x and then doing a second JOIN WHERE Foo IN ( the Foos returned from the first JOIN )? I've fooled around with it, but can't seem to find anything that works. *Yet it's such a common thing to do that I have to suppose there's a better solution than brute-force. TIA for any thoughts.- Hide quoted text - - Show quoted text - |
#2
| |||
| |||
|
|
But so far, although I can describe what I want in English, I can't seem to map that onto SQL. Whatever I do, I end up with multiple copies of the base record each glued to one of the fanout records whereas what I need is all the fanout records for one base record glued to one copy of that base record, or a way to determine how many of those 1:1 intermediate records will make up that one finished record so that I can trick the limit. What's another pain is that I have 3 heavyweight db books including Date and none of them covers this situation. |
![]() |
| Thread Tools | |
| Display Modes | |
| |