|
|
how to write such SQLs?
I have two table: A and B.
I want to implements:
for each A.primaryKey
to select 3 recoders from B where B.a = A.primaryKey then return the results
select 3 recoders from B where B.a = A.primaryKey
But which 3? And why 3?
I want to:
var results1 = select * from A
var resultsTotal
while (results1 has next) {
var resultsTemp = select top 3 * from B where b.a = a.x resultsTotal += resultsTotal
}
how to use sql for implements?
quot;Top nquot; query SQL varies by database. I'd suggest a good SQL reference or googling for quot;top nquot; and your database. You might also how to think about you're going to get the a * 1, b* 3 result rows into a tabular form... |
|