du20150401 2014-10-30 15:34
浏览 34
已采纳

混合数据库中两个表的数据

I have two tables, one called location_name it looks like this,

location  shortname longname  precolor     color     hidden

       1    STO     Stockholm   #00FF00     #FF0000     0
       2    GBG     Gothenburg  #00FFFF     #FF00FF     0
       3    MMO     Malmö      #C6C6C6     #008000     0
       4    CPH     Copenhagen  #FF0080     #FF8000     0
       5    ARH     Ã…rhus      #80FF80     #8000FF     1
       6    SER     Service     #FFFF00     #FFFF00     1

and the other one, called art_tot, looks lite this

artnr   art     art_text     gnr       gnr_group    sortorder   hide    location    
220101  Thing   description  2201      1            101         0       3
220102  Thing   description  2201      1            102         0       2 
220103  Thing   description  2201      1            103         0       3 

and im making a that looks something like this

 Pos    Equipment   Artnr  Mon 27-10-2014   Tue 28-10-2014  Wed 29-10-2014  Thu 30-10-2014  Fri 31-10-2014  Sat 01-11-2014  Sun 02-11-2014
 STO    Thing       220101
 STO    Thing       220102
 STO    Thing       220103
 STO    Thing       222001

What i need to do is, color the Pos to the correct color from location_name and have the correct shortname and have the title be the longname.

So i somehow have to make the the Pos TD get the correct values from location_name based on the location column from art_tot

Or is there a simpler way to do this?

  • 写回答

1条回答 默认 最新

  • drug95107 2014-10-30 20:17
    关注

    i read about JOIN and ended up doing :

    $sql ="SELECT a.art_text , a.art , a.art , a.artnr , b.color , b.longname, b.shortname
            FROM art_tot a , location_name b 
            where gnr_group =1 AND a.location = b.location
            order by sortorder" ;
    

    It works like a charm, thanks @dwhite.me

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败
  • ¥15 Centos7 / PETGEM
  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题