Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help joining tables to one table

Author  Topic 

lalov1
Starting Member

1 Post

Posted - 2010-07-09 : 11:55:25
I have four different tables called residential, commercial, multi_family, and land. They all have images stored in an images table. Also, they all have a mls column with a unique number, but none of the tables share the same mls number. The images table is the only one that has a mls numbers for all four of the other tables.

The following works for the residential table just like I want:
SELECT * FROM `residential` INNER JOIN `images` as i on i.mls = residential.mls WHERE i.photoOrder = 0;

Would I be able to join all four tables to the images table? I'm new to all this and didn't set-up the structure.

Thank you,
Lallo

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2010-07-09 : 12:05:35
Please post the DDL of the tables - so we can see keys ,columns , definitions etc,
Is the mls number of the individual tables a foreign key of the images table?

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page
   

- Advertisement -