subquery help

  • Thread starter Thread starter Tiziana
  • Start date Start date
T

Tiziana

I have this cadastre table:

ID_REAL ESTATE ID_OWNER SHEET NUMBER SUB

649564 934248 18 242 4
649564 1131665 18 242 4

I need to achieve only one record like this

ID_REAL ESTATE SHEET NUMBER SUB ID_OWNER1 ID_OWNER2

649564 18 242 4 934248 1131665


Thanks for any info you can provide.
 
Dear Tiziana:

As a former land surveyor, I can see what your are attempting.

Now, how would you show that if there are 3 owners. I know that can
happen. Or what if there are 4 owners, 5 owners, or 999 owners.

I would guess you are "thinking spreadsheet" and not database.

A good database design would have two tables. One table would have
only one row per property. This would contain:

ID_REAL ESTATE / SHEET / NUMBER / SUB

The other table would form a many-to-many relationship between the
above table and your owner table, from which you obtain ID_OWNER.
This table would contain only [ID_REAL ESTATE] and ID_OWNER. This
would then contain a "list" of the owners of each property, or viewed
the other way round, a "list" of the properities for any given owner.

The above is standard, "Normalized" practice for database design, and
is strongly recommended for your needs. In the long run, it will
support complex query capabilities that would be difficult to
impossible given your current design. For example, if you put the
Owner into multiple columns as you have shown, how would you then list
all the properties for a selected Owner? Not easily, and the more so
if you show 3, 4, or 999 owners in the same way.

Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
 
Back
Top