G
Guest
I am trying to create a view that returns data from three tables and can't
seem to get it to return the data that I want. I am no SQL expert, so
hopefully someone can give me some insight into what I need to do.
The tables are basically set up like this:
TABLE 1
PrimaryKey
Textfield1
Textfield2
Textfield3
TABLE 2
PrimaryKey
Table1ForeignKey
Table3ForeignKey
Textfield1
TABLE 3
PrimaryKey
Textfield1
Textfield2
Textfield3
Table 1 and Table 3 are each joined to Table 2 on their respective
Primary/Foreign Key fields, essentially creating a many-to-many relationship
between tables 1 and 3.
I want the view to return all of the records from Table 1, even if there are
no matching records in Table 2.
From Table 2 I only want the latest (MAX(PrimaryKey)) record for each record
in Table 1.
I want the view to look something like this:
Table 1 Table1 Table2 Table3
PrimaryKey Textfield1 Textfield Textfield
In other words, I want to return one record in the view for each record in
table 1, and I want the data from table 2 in each of those records to
represent the last record added to table 2.
Can anyone enlighten me on the query necessary to get this view?
seem to get it to return the data that I want. I am no SQL expert, so
hopefully someone can give me some insight into what I need to do.
The tables are basically set up like this:
TABLE 1
PrimaryKey
Textfield1
Textfield2
Textfield3
TABLE 2
PrimaryKey
Table1ForeignKey
Table3ForeignKey
Textfield1
TABLE 3
PrimaryKey
Textfield1
Textfield2
Textfield3
Table 1 and Table 3 are each joined to Table 2 on their respective
Primary/Foreign Key fields, essentially creating a many-to-many relationship
between tables 1 and 3.
I want the view to return all of the records from Table 1, even if there are
no matching records in Table 2.
From Table 2 I only want the latest (MAX(PrimaryKey)) record for each record
in Table 1.
I want the view to look something like this:
Table 1 Table1 Table2 Table3
PrimaryKey Textfield1 Textfield Textfield
In other words, I want to return one record in the view for each record in
table 1, and I want the data from table 2 in each of those records to
represent the last record added to table 2.
Can anyone enlighten me on the query necessary to get this view?