[thelist] SQL for what I think might be many to many

John Corry webshot at members.evolt.org
Fri Apr 19 16:59:01 CDT 2002


> However, if the names are unique enough, I'd suggest not using the IDs,
> but the names of the condos and beaches instead. That way you cut down
> on the traffic going to the db. In this above table, you'd have to make
> your SQL call to get the beaches within walking distance, then you'd
> have to make more SQL calls to get the names of the beaches and the
> condos based on the ID numbers the first call returned. That can get a
> bit slow depending on your DBMS, server setup, and the algorithm used.

Really? How so? I'm using PHP/MySQL.

I'm thinking that if I have this 'joiner' table in place, then I can
generate SQL to get all the info I need in not more than one query (and it
will always take at least one query to get anything)...so I don't see the
increased traffic...

SELECT [fields I want] FROM beaches_table, condo_table,
walking_distance_table WHERE beaches_table.beach_id =
walking_distance_table.beach_id

wouldn't that return everything I need to display:
the beach info
which condos are walking distance away
the condo info for those condos
?

John




More information about the thelist mailing list