$strSQL = "SELECT * FROM member
INNER JOIN prename ON member.precode=prename.precode
INNER JOIN location ON member.subprov=location.subprov
INNER JOIN location ON member.prov=location.prov
where $w member.prov=location.prov and member.isstatus='Y' order by member.unit asc ,member.membc asc ";
$objExec = odbc_exec($cn, $strSQL) or die ("Error Execute [".$strSQL."]");
INNER JOIN location ON member.prov=location.prov AND member.subprov=location.subprov
คำสั่งข้างบนเทียบเท่าคำสั่งของ VFP
Code
USE Members IN 0 EXCLUSIVE
INDEX ON prov + subprov TAG ManyToMany
USE IN Members
USE Location IN 0 EXCLUSIVE
INDEX ON prov + subprov TAG ManyToMany
USE IN Location
USE Members IN 0 SHARED TAG ManyToMany
USE Location IN 0 SHARED TAG ManyToMany
SELECT Members
SET RELATION TO ManyToMany INTO Location
SEEK '31032553'
IF FOUND()
BROWSE NOWAIT
SELECT Location
BROWSE NOWAIT
ENDIF
Good Luck.
Date :
2014-03-07 09:48:25
By :
love9713
No. 5
Guest
อย่าลืม SET DELETE ON ด้วยครับ (จากรูปข้างบนมันดูน่าเกลียด)
CREATE VIEW vwLocation
AS SELECT * FROM Location
WHERE (subprov IS NULL ) OR subprov = '00'
Finally SQL Query ของคุณก็จะเป็นดังนี้
Code (SQL)
SELECT *, vwLocation.Lname FROM member
INNER JOIN prename ON member.precode=prename.precode
INNER JOIN t_contract ON member.membc=t_contract.memberid
INNER JOIN location ON member.prov=location.prov AND member.subprov=location.subprov
INNER JOIN vwLocation ON vwLocation.prov = member.prov
INNER JOIN m_loan ON t_contract.loanid=m_loan.loanid
WHERE (membc LIKE '%".$id."%' )