Page is a not externally linkable
- Code, Content, and Presentation
-- Databases
---- Ambiguity in selection with multiplly linked tables


andreasfriedrich - 5:29 am on Jan 27, 2007 (gmt 0)


Access is prompting for two values because it does not know the values of organis.ID and speak.company. You are trying to alias the table names but you need to do it in the table references instead of the field list.

Given three tables

orgs
====
id
name

events
======
id
org_id
speaker_id

speaker
=======
id
name

the following query will give you a list of events with their speaker and organization:

SELECT o.name AS OrgName,
e.name AS Event,
s.name AS Speaker
FROM orgs AS o,
speaker AS s,
events AS e
WHERE o.id = e.org_id
AND e.speaker_id = s.id
AND s.id = e.speaker_id;

If there is a many to many relation between speakers and events you should use a cross reference table.

And btw the query you posted is already using joins in your query.


Thread source:: http://www.webmasterworld.com/databases_sql_mysql/3231657.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com