select c.comp_Id,c.comp_name,city_name+coun_name+comp_detail_address as address,comp_phone,comp_homepage,comp_urllogo,user_role,bgcolor='#FFFFFF'
from tbl_city city,tbl_country country, tbl_company c join tbl_user u
on c.comp_id=u.company_id
where
city.city_id=country.city_id and city.city_id='18'
and
c.comp_address_county=country.coun_id
GO
修改后:
select comp_id, comp_name,city_name+coun_name+comp_detail_address as address,comp_phone,comp_homepage,comp_urllogo,user_role,bgcolor='#ffffff'
from tbl_company comp
join
(select city_name,city_id from tbl_city) city
on comp.comp_address_city=city.city_Id and city.city_id='18'
join
(select coun_id,coun_name from tbl_country) coun
on comp.comp_address_county=coun.coun_id
join
(select company_id,user_role from tbl_user) users
on comp.comp_id=users.company_id
还是不能提高查询速度,郁闷!!!
记得学习关系代数的时候,原则是先选择,后连接。总算用上一会,可是还是不能提高效率.晕