473,320 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

REQ: Help with M:N cross referenced tables requested

Dear databasers,

here's what I need to accomplish in mysql:

Table "person":
Fields: pid, name, email

Table "address":
Fields: aid, street, city, zip, state, validfrom

Table "xref_pers_addr":
Fields: refid, pid, aid, timestamp

for security reasons I want to configure the user's access to the
database to be write only, no delete or drop should be allowed. Hence
when an address of a person has to be updated (e.g. because he or she
moved) a ne entry has to be made in the address table with an updated
"validfrom" field. In the long run there will be more than one address
entry per person, and only the youngest entry is the valid one. Which
SQL query allows to get a list like

pid, name, street, city, zip, state, validfrom

that only shows the latest address per person?

I assume there must be an sql hack for mysql version < 4.0 which
accomplishes that without using subqueries that are only available in
mysql >=4.1. which i do not intend to deploy on my server.

My guess was this:

SELECT pid, name, CONCAT(MAX(validfrom)," ", street," ", city," ",
zip," ", state) FROM person,address,xref_pers_addr WHERE
person.pid=xref_pers_addr.pid AND address.aid=xref_pers_addr.aid GROUP
BY pid;

That grabs only the latest address, but I obtain the whole address in
one field an I have to disassemble it later into the respective fields
which is quite cumbersome.

Any other option to do that without using subqueries?

Best regards and thanks in advance - dudelman.
Jul 19 '05 #1
0 852

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dudelman | last post by:
Dear databasers, here's what I need to accomplish in mysql: Table "person": Fields: pid, name, email Table "address": Fields: aid, street, city, zip, state, validfrom
0
by: Tim Sawlor | last post by:
I am looking for an XML document management systems that might meet my requirements. The group I work for produces a great deal of reports and documents. These documents can be quite long (~300+...
2
by: Andrew Connell | last post by:
I have an application where the authentication is based off another site (custom portal). The portal authenticates the user(s). Then, when they select an application, they are routed to the...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.