You can just specify another join..Declare @countries table (country_id int not null, country varchar(20) not null)INSERT INTO @countriesSELECT 1 ,'USA' UNIONSELECT 2, 'Germany'DECLARE @cities table ( city_id int not null,country_id int not null,city varchar(25) not null )INSERT @citiesSELECT 1 ,1 ,'california' UNIONSELECT 2, 2, 'Munich'DECLARE @clients TABLE (client_id int not null,client_name varchar(20) not null,city_id int not null,resident_id int not null)INSERT @clientsSELECT 1 ,'michael', 1, 2 UNIONSELECT 2 ,'john' ,2, 1SELECT client_id, client_name,city,t.country as resident_country,t2.country as countryFROM @clients c inner join @cities s on c.city_id = s.city_id inner join @countries t on c.city_id = t.country_id inner join @countries t2 on c.resident_id = t2.country_id
Might be easier to have a ResidentCountry and Country tables as separate though...
Poor planning on your part does not constitute an emergency on my part.