I select records with A=true, sort by B, and then limit it to C records, where C is an integer.
When all records are A=true, I get back C records.
For every record that A=false, I get back 1 less record than C.
So, my table now has 4 records where A=false, so it's showing C-4 records.
Kinda hard to explain, but that's not expected behaviour. I want it to FIRST find C records A=true, THEN sort them, such that I always receive C amount of records. I basically want it to find me C records where A=true, sort them by B, as apposed to finding C records then REMOVING the ones where A=false then sorting by B. Any tips?
Well.. Here's my table, columns are Name, Age, Display
Bob, 10, 1
Fred, 15, 1
Jim, 20, 1
Dan, 14, 0
I want to get 2 records which have "Display" set to 1, ordered by Age.
Right now, I get Bob, just Bob. This is because the table is sorted, then limited, then the records with Display=1 are returned (which means only 1).
What I want is to get Bob and Fred, because they are the first 2 records when you sort by Age and ignore Display=0 records.
Understand now?
When all records are A=true, I get back C records.
For every record that A=false, I get back 1 less record than C.
So, my table now has 4 records where A=false, so it's showing C-4 records.
Kinda hard to explain, but that's not expected behaviour. I want it to FIRST find C records A=true, THEN sort them, such that I always receive C amount of records. I basically want it to find me C records where A=true, sort them by B, as apposed to finding C records then REMOVING the ones where A=false then sorting by B. Any tips?
Well.. Here's my table, columns are Name, Age, Display
Bob, 10, 1
Fred, 15, 1
Jim, 20, 1
Dan, 14, 0
I want to get 2 records which have "Display" set to 1, ordered by Age.
Right now, I get Bob, just Bob. This is because the table is sorted, then limited, then the records with Display=1 are returned (which means only 1).
What I want is to get Bob and Fred, because they are the first 2 records when you sort by Age and ignore Display=0 records.
Understand now?