|
|
|
Please help use INNER join multiple tables in sqlsrv with php |
|
|
|
|
|
|
|
Let me give you an example of INNER JOIN Table in php connected to sqlsrv.
I did a post but reported an error.
Thank you very much!
Quote:<?php
$serverName = "SQLSERVER";
$userName = "sa";
$userPassword = "123456";
$dbName = "Product";
$connectionInfo = array("Database"=>$dbName,"characterSet"=>"UTF-8", "UID"=>$userName, "PWD"=>$userPassword, "MultipleActiveResultSets"=>true);
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false ) {
die( print_r( sqlsrv_errors(), true));
}
$sql = "SELECT * FROM NhanVien
INNER JOIN DM_PhongBan ON TenNhanVien.PhongBan_id = DM_PhongBan.PhongBan_id";
$stmt = sqlsrv_query($conn, $sql);
$params = array();
/* Retrieve each row as an associative array and display the results.*/
while( $row = sqlsrv_fetch_object( $stmt, SQLSRV_FETCH_ASSOC))
{
echo $row['MaNhanVien'].", ".$row['TenNhanVien']."\n";
}
/* Free statement and connection resources. */
//sqlsrv_free_stmt( $stmt);
sqlsrv_close( $conn);
?>
Warning: sqlsrv_fetch_object() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\MyPHP\search.php on line 22
Tag : PHP, FuelPHP
|
|
|
|
|
|
Date :
2019-08-23 22:52:18 |
By :
rainkv |
View :
826 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Thank You Very Much
|
|
|
|
|
Date :
2019-08-24 15:16:50 |
By :
rainkv |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|