my query returns 2 rows second exact duplicate of first. know reason why happening? know if put limit 1 in end return single row request not suggest solution. here query
select u.username,u.password,u.registerdate,u.lastvisitdate,u.lastvisitip, u.activationstring, u.active,u.block,u.contact_id,c.name,c.email,c.pphone,c.sphone,c.rphone,c.area_id, a.name areaname, a.city_id, ct.name cityname, ct.state_id, s.name statename, s.country_id, cn.name countryname users u left join contacts c on (u.contact_id = c.id) left join areas on (c.area_id = a.id) left join cities ct on (a.city_id = ct.id) left join states s on (ct.state_id = s.id) left join countries cn on (s.country_id = c.id) u.id = 1
above query fetching data 6 tables includes
users s contacts c areas cities ct states s country cn
all 6 tables above have primary key named id
foreign keys follows
users.conntact_id contacts.area_id areas.city_id cities.state_id states.country_id
why returning 2 rows instead of one?
one of tables join has more 1 element, others repeated. table contacts
table.
Comments
Post a Comment