我有两个表,一个名为location_name,它看起来像这样,
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
另一个名为art_tot,看起来很简单
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
我正在做一个看起来像这样的
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
我需要做的是,将Pos的颜色设置为location_name的正确颜色,并使用正确的短名称,并将标题设为长名称。
所以我不得不让Pos TD根据art_tot的位置列从location_name获取正确的值
或者有更简单的方法吗?
答案 0 :(得分:1)
我读到了JOIN并最终做了:
$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" ;
它就像一个魅力,谢谢@ dwhite.me