在我的数据库中,我有 5 个名称为 'children' 、 'personal' 、 'spouse' 、 'occup_contact' 、 'res_contact' 的表,列名
children(pid,pnochild,pcname,pcblood,pcdob)
occup_contact(pid,poccup_nature,poccup_type,poccup_add,pemail,poccup_phone,poccup_mobile)
personal(pid,pname,pfname,pmname,pfhname,pdob,pgender,pedulvl,pedu,pblood,gotra,panth,pmarritalstatus)
res_contact (pid,pres_add,pres_phone,pres_mobile)
spouse (pid,psname,psedulvl,psedu,psblood,psdob)
然后在我的表单上,我拖动了一个数据网格视图,我想将所有这些表的结果与修改后的列名连接起来,例如
name not 'pname' it should be Name
fathername not 'pfname' it should be Father's Name........so on
以及我应该使用哪个选择语句来获取基于人名的所有表的连接结果,即个人表的 pname 列,其中个人表的 pid 列是主键并在所有其他表中用作外键。所有表都依赖于个人表
我用过这个
cmd.CommandText = "select p.pname as 'Name',p.pfname as 'Father Name' ,p.pmname as 'Mother Name',p.pfhname as 'Family Head Name',p.pdob as 'Date of Birth',p.pgender as 'Gender',p.pedulvl as 'Education',p.pedu as 'Degree',p.pblood as 'Blood Group',p.gotra as 'Gotra',p.panth as 'Panth',p.pmarritalstatus as 'Marrital Status',s.psname as 'Spouse Name',s.psedulvl as 'Spouse Edu. Degree',s.psedu as 'Spouse Education',s.psblood as 'Spouse Blood Group',s.psdob as 'Spouse Date of Birth',c.pnochild as 'Number of Children',c.pcname as 'Child Name',c.pcblood as 'Child Blood Group',c.pcdob as 'Child Date of Birth',r.pres_add as 'Resident Address',pres_phone as 'Resident Ph.no ',pres_mobile as 'Resident Mobile no.',o.poccup_nature as 'Nature of Occupation',o.poccup_type as 'Type of Occupation',o.poccup_add as 'Office Address',o.pemail as 'Email id',o.poccup_phone as 'Office Ph.no',o.poccup_mobile as 'Office Mobile number'from personal as p join spouse as s on p.pid=s.pid join children as c on p.pid=c.pid join occup_contact as o on p.pid=o.pid join res_contact as r on p.pid=r.pid where pname='" + viewtxt.Text + "' ";