Ask a Question related to Coldfusion Database Access, Design and Development.
-
c1natra #1
Querying related tables
Simple query question -
I have a real estate table with various fields (Beds, Baths, SqFt, etc). One
of the fields is BrokerID, which is foreign key linked to the primary key in
the Broker table which holds names and contact info for each broker. I
understand table relationships and what not. No problem there.
Where I am lost is in the SQL query...here's an example.
SELECT *
FROM RealEstateTable
WHERE RealEstateID = 1
Let's say this query returns a record with a BrokerID of 3. How do I go about
pulling the appropriate broker info from the Broker table?
I know this is easy, but I'm not getting it.
Thanks for everyone's time...Bill
c1natra Guest
-
Querying one-to-many tables
Hi, I have a database with, for the sake of simplicity, two tables with a one-to-many relationship. The first table is the user info and the... -
Querying data that matches in two different tables
The code is attached. Basically there are two tables, contact and recruiter. When you initially add someone to contact, it also adds certain... -
Querying for unmatched records in two tables
I have two tables - One contains a list of all the zip codes in the US. The other table is basically a mailing list containing addresses of people... -
querying a view of a lot tables
I have setup a database to record our IP Account from ALL of our routers in a form. It's very slow and sometimes times out.. which is NO GOOD.. I... -
SHOW TABLES and related options for SQL are not working
Hi, I have installed Perl from Active State.com in Win2K advanced server and no other Packages are installed. I am able to connect to Sql server... -
Dan Bracuk #2
Re: Querying related tables
select just the fields you want, not *
from realestatetable r, brokertable b
where t.brokerid = b.brokerid
and maybe other constraints
Originally posted by: c1natra
Simple query question -
I have a real estate table with various fields (Beds, Baths, SqFt, etc). One
of the fields is BrokerID, which is foreign key linked to the primary key in
the Broker table which holds names and contact info for each broker. I
understand table relationships and what not. No problem there.
Where I am lost is in the SQL query...here's an example.
SELECT *
FROM RealEstateTable
WHERE RealEstateID = 1
Let's say this query returns a record with a BrokerID of 3. How do I go about
pulling the appropriate broker info from the Broker table?
I know this is easy, but I'm not getting it.
Thanks for everyone's time...Bill
Dan Bracuk Guest
-
c1natra #3
Re: Querying related tables
Thanks Dan -
I'm assuming the "t" should be an "r"?
select just the fields you want, not *
from realestatetable r, brokertable b
where r.brokerid = b.brokerid
So then I simply call the broker information like this?
<cfoutput query="queryname">#b.BrokerInfo#</cfoutput>
Thanks for the quick reply...
Bill
c1natra Guest
-
paross1 #4
Re: Querying related tables
No, you don't include the table prefix in the field output. If the field name
in the table is BrokerInfo, that is what you put, even though you may have
added the table prefix in the select statement.
<cfoutput query="queryname">#BrokerInfo#</cfoutput>
Phil
paross1 Guest
-



Reply With Quote

