I have 2 tables like these:-
Table: offers
|-------------- |
| id | OfferNum |
| 1 | a1 |
| 2 | a2 |
| 3 | a3 |
| 4 | a4 |
| 5 | a5 |
| 6 | a6 |
|---------------|
Table: colours
|------------------------------------------|
| id | OfferNum | colour | availaility |
| 1 | a1 |blue |yes |
| 2 | a1 |red |no |
| 3 | a2 |green |yes |
| 4 | a3 |white |yes |
| 5 | a3 |brown |yes |
| 6 | a3 |navy |no |
| 7 | a3 |black |yes |
| 8 | a3 |red |yes |
| 9 | a4 |yellow |no |
| 10 | a5 |black |yes |
| 11 | a6 |white |yes |
|------------------------------------------|
For pagination purposes, I need to select 3 OfferNums from table "offers", starting from offset 0, and join the two tables so that the resultant rows would contain the 3 offernums (i.e a1, a2, and a3). And so on..
The following script, with LIMIT 0,3 does not produce the desired result.
SELECT offers.OfferNum, items.colour, items.availability
FROM offers
JOIN items ON items.OfferNum = offers.OfferNum
ORDER BY offers.id ASC
LIMIT 0 , 3
it yields the first 3 rows of the joined tables only. Like so:-
|----------------------------|
|OfferNum|colour|availability|
|a1 |blue |yes |
|a1 |red |no |
|a2 |green |yes |
|----------------------------|
Is there a way to achieve the desired result?