日期:2014-05-16  浏览次数:20878 次

横表inner join竖表
phpwind论坛中有两个表是这样的
pw_usergroups
gid gptype grouptitle groupimg grouppost ifdefault
1 default default 0 0 1
2 default 游客 0 0 0
3 system 管理员 10 0 0
4 system 总版主 9 0 0
5 system 论坛版主 6 0 0
6 default 禁止发言 0 0 0
7 default 未验证会员 0 0 0
8 member 生人练手 0 0 0
9 member 新生力量 1 100 0
10 member 乐在其中 2 300 0
11 member 以站为家 3 600 0
12 member 本站控 4 1000 0
13 member 贡献大大地 5 5000 0
14 member 神马达人 6 10000 0
15 member 荣誉股东 7 50000 0
16 special 荣誉会员 11 0 0
17 system 门户编辑 8 0 0

pw_perssion
uid没用 fid没用 gid关联 rkey type没用 rvalue值
0 0 1 allowvisit basic 1
0 0 1 maxmsg basic 30
0 0 1 allowhide basic 0
0 0 1 allowread basic 1
0 0 1 allowportait basic 1
0 0 1 upload basic 1
0 0 1 allowrp basic 1
0 0 1 allowhonor basic 1
0 0 1 allowdelatc basic 1
0 0 1 allowpost basic 1
0 0 1 allownewvote basic 1
0 0 1 allowvote basic 1
0 0 1 allowactive basic 1
0 0 1 htmlcode basic 0
0 0 1 allowhidden basic 1
0 0 1 allowencode basic 1
0 0 1 allowsell basic 1
0 0 1 allowsearch basic 2
0 0 1 allowmember basic 1
0 0 1 allowprofile basic 1
0 0 1 allowreport basic 1
0 0 1 allowmessege basic 1
0 0 1 allowsort basic 1
0 0 1 alloworder basic 1
0 0 1 allowupload basic 1
0 0 1 allowdownload basic 1
0 0 1 allownum basic 50
0 0 1 edittime basic 0
0 0 1 postpertime basic 3
0 0 1 searchtime basic 10
0 0 1 signnum basic 100
0 0 1 show basic 1
0 0 1 viewipfrom basic 0
0 0 1 imgwidth basic
0 0 1 imgheight basic
0 0 1 msggroup basic 0
0 0 1 maxfavor basic 100
0 0 1 viewvote basic 0
0 0 1 atccheck basic 1
0 0 1 markable basic 1
0 0 1 postlimit basic
0 0 1 uploadtype basic
0 0 1 markdt basic
0 0 1 ifmemo basic 1
0 0 1 atclog basic 1
0 0 1 modifyvote basic 1
0 0 1 allowreward basic 1
0 0 1 allowgoods basic 1
0 0 1 allowdebate basic 1
0 0 1 anonymous basic 0
0 0 1 dig basic 1
0 0 1 leaveword basic 1
0 0 1 schtime basic 7776000
0 0 1 fontsize basic
0 0 1 maxsendmsg basic
0 0 1 pergroup basic member
0 0 1 maxgraft basic 5
0 0 1 pwdlimitime basic
0 0 1 maxcstyles basic
0 0 1 media basic flash,wmv,rm,mp3
0 0 1 markset basic a:5:{s:5:"money";a:4:{s:9:"markctype";s:5:"money";s:9:"maxcredit";s:1:"5";s:9:"marklimit";a:2:{i:0;s:1:"1";i:1;s:1:"2";}s:6:"markdt";s:1:"0";}s:4:"rvrc";a:3:{s:9:"maxcredit";s:0:"";s:9:"marklimit";a:2:{i:0;s:0:"";i:1;s:0:"";}s:6:"markdt";s:1:"0";}s:6:"credit";a:3:{s:9:"maxcredit";s:0:"";s:9:"marklimit";a:2:{i:0;s:0:"";i:1;s:0:"";}s:6:"markdt";s:1:"0";}s:8:"currency";a:3:{s:9:"maxcredit";s:0:"";s:9:"marklimit";a:2:{i:0;s:0:"";i:1;s:0:"";}s:6:"markdt";s:1:"0";}i:1;a:3:{s:9:"maxcredit";s:0:"";s:9:"marklimit";a:2:{i:0;s:0:"";i:1;s:0:"";}s:6:"markdt";s:1:"0";}}
这个表的内容包含gid从1到17,我这里仅仅列出gid等于1的來示意,下面gid=2到17的也是类似的数据
实际上这个表的内容完全可以放到上面的表中,但是人家已经设计成这样了,
其实像allowvisit,maxmsg,allowhide,这些等等都可以作为上面表中的字段存在。

我现在就是要写一条语句,用gid进行关联然后显示出来所有的数据
如下:

gid gptype grouptitle groupimg grouppost ifdefault allowvisit maxmsg allowhide .........
1 default default 0 0 1 这边读出相应的数据过来
2 default 游客 0 0 0
3 system 管理员 10 0 0 这边读出相应的数据过来
4 system 总版主 9 0 0
5 system 论坛版主 6 0 0 。。。。。。
6 default 禁止发言 0 0 0 。