0

I have to tables:

Table A:
CName           |   Id
-------------------------------
John Smith      | 1
Jane Doe        | 4
John Smith      | 9
Joe Bloggs      | 10

Table B:
Id       |   IdUser          |   state
-------------------------------
1        |    1              | PD
2        |    4              | AS
3        |    1              | JT
4        |    1              | PD
5        |    1              | PD
6        |    4              | JT
7        |    1              | JT
8        |    4              | PD
9        |    4              | JT

The relation of tables is A can have several B and B can have only one A (A1-*B).

I need to create a query to get the first 3 lines of table B, for each line of table A

So in this example the result will be:

CName           |   Id(A)   |    Id(B)     |    state
-------------------------------------------------------
John Smith      | 1         |      1       |     PD
John Smith      | 1         |      3       |     JT
John Smith      | 1         |      4       |     PD
Jane Doe        | 4         |      2       |     AS
Jane Doe        | 4         |      6       |     JT
Jane Doe        | 4         |      8       |     PD
Iban Arriola
  • 2,526
  • 9
  • 41
  • 88

0 Answers0