Relationship problem, newbie problem, need help!

Hey all

I seem to be having some problems with my relationship between a few
tables…

If i then run the following query in mysql, i get the data i want. How
do i do this in rails relationships and models?

select * from shop_addresses
left join shops on shops.id = shop_addresses.shop_id
left join styles on styles.id = shops.style_id
where shop_uri = ‘127.0.0.1’

Cheers!!

Tim P.

PS: The tables are the following…

#----------------------------

Table structure for styles

#----------------------------
CREATE TABLE styles (
id int(11) NOT NULL auto_increment,
css_file text,
asset_path text,
PRIMARY KEY (id),
KEY id (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

#----------------------------

Table structure for shops

#----------------------------
CREATE TABLE shops (
id int(11) NOT NULL auto_increment,
affiliate_id int(11) default NULL,
shop_configurtaion_id int(11) default NULL,
style_id int(11) default NULL,
shop_name varchar(200) default NULL,
shop_desc text,
PRIMARY KEY (id),
KEY affiliate_id (affiliate_id),
KEY affiliatesbrands (affiliate_id),
KEY id (id),
KEY shop_configurationsshops (shop_configurtaion_id),
KEY shop_configurtaion_id (shop_configurtaion_id),
KEY style_id (style_id),
KEY stylesbrands (style_id),
CONSTRAINT shops_ibfk_1 FOREIGN KEY (affiliate_id) REFERENCES
affiliates (id),
CONSTRAINT shops_ibfk_2 FOREIGN KEY (shop_configurtaion_id)
REFERENCES shop_configurations (id),
CONSTRAINT shops_ibfk_3 FOREIGN KEY (style_id) REFERENCES styles
(id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

#----------------------------

Table structure for shop_addresses

#----------------------------
CREATE TABLE shop_addresses (
id int(11) NOT NULL auto_increment,
shop_id int(11) default NULL,
shop_uri varchar(200) default NULL,
PRIMARY KEY (id),
KEY brand_id (shop_id),
KEY brandsbrand_uri (shop_id),
KEY id (id),
CONSTRAINT shop_addresses_ibfk_1 FOREIGN KEY (shop_id) REFERENCES
shops (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Found a problem! sorry for posting!

Tim