zoukankan      html  css  js  c++  java
  • Sql语句——多表查询

    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
    还是不能提高查询速度,郁闷!!!
    记得学习关系代数的时候,原则是先选择,后连接。总算用上一会,可是还是不能提高效率.晕

    人的一生应该这样度过:当他回首往事的时候,不会因为虚度年华而悔恨,也不会因为碌碌无为而羞愧。
  • 相关阅读:
    p4 view mapping及其特殊字符
    Build Release Blogs
    Linux技术blogs
    为什么使用tmux
    linux下安装wine
    PythonDjango的windows环境
    tmux安装
    基于云端的开发平台Team Foundation Service
    linux网络配置之setup命令
    Centos6.2设置静态ip和dns
  • 原文地址:https://www.cnblogs.com/htht66/p/882643.html
Copyright © 2011-2022 走看看