php - select inner join 4 tables -



php - select inner join 4 tables -

so want specific info table number 4 interconnected other 3 table user take $faid , print info needed

table 1 (dbo.faid) faid(pk) pcid(fk) userid(fk)

table 2 (dbo.users) userid(pk) employeename

table 3(dbo.subdepttransfer) transferid(pk) userid(fk) subdeptid(fk)

table 4 (subdept) subdeptid(pk) deptid(fk)

table 5(department) deptid(pk) section

<?php $faidf=$_post['faidf']; ini_set("display_errors","on"); $conn = new com("adodb.connection"); seek { $myserver = "wtcphfilesrv\wtcphinv"; $myuser = "sa"; $mypass = "p@ssw0rd"; $mydb = "wtcphitinventory"; $connstr = "provider=sqloledb;server=".$myserver.";uid=".$myuser.";pwd=".$mypass.";database=".$mydb; $conn->open($connstr); if (! $conn) { throw new exception("could not connect!"); } } grab (exception $e) { echo "error (file:): ".$e->getmessage()."<br>"; } if (!$conn) {exit("connection failed: " . $conn);} echo "<center>"; echo "<table border='0' width ='100%' style='margin-left:90px'><tr><th></th><th></th></tr>"; $sql_exp = "select e.department dbo.fa_pc inner bring together dbo.users b on a.userid = b.userid inner bring together dbo.subdepttransfer c on a.userid = c.userid inner bring together dbo.subdept d on a.subdeptid = d.subdeptid inner bring together dbo.department e on a.deptid = e.deptid a.faid = $faidf"; $rs = $conn->execute($sql_exp); echo "<tr><td>".$rs->fields("department")."</tr></td>"; $rs->close(); ?>

all "invalid column name 'subdeptid" im column name right though think mess select statement

faid->users->subdepttransfer->subdept->department

is there conflict of how many inner joins has been made or cannot execute more 3 tables? if yes there way connect 5 tables?

there no restriction afaik, @ to the lowest degree 5 tables should not problem. in case there typo in sql statement. utilize alias a, think meant utilize c (i have fixed deptid - next error after prepare subdeptid). seek statement

select e.department dbo.fa_pc inner bring together dbo.users b on a.userid = b.userid inner bring together dbo.subdepttransfer c on a.userid = c.userid inner bring together dbo.subdept d on c.subdeptid = d.subdeptid inner bring together dbo.department e on d.deptid = e.deptid a.faid = $faidf

php sql-server select datatable

Comments

Popular posts from this blog

javascript - mongodb won't find my schema method in nested container -

Hibernate criteria by a list of natural ids -

ios - Lagging ScrollView with UIWebview inside -