้มันฟ้องว่า
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Code (PHP)
$querycheck = "SELECT * FROM LocalAdmin_TempUpload";
$resultcheck = sqlsrv_query($conn, $querycheck);
while($rowcheck = sqlsrv_fetch_array($resultcheck, SQLSRV_FETCH_ASSOC)){
$getmacname = $rowcheck['machine_name'];
//echo $getmacname."<br>";
$queryupdate = "UPDATE LocalAdmin_TempUpload SET family_name = (SELECT t1.family_name FROM LocalAdmin_FamilyName t1 INNER JOIN LocalAdmin_TempUpload t2
ON t2.machine_name LIKE '%'+t1.family_name+'%' WHERE t2.machine_name = '".$getmacname."')";
ส่วน query ด้านล่างนี้ใช้ใน sql studio ละผลลัพท์เป็นตามต้องการละครับ เลยใส่เข้าไป php
Code (SQL)
select t1.family_name from [SecurityTools].[dbo].[LocalAdmin_FamilyName] t1 INNER JOIN [SecurityTools].[dbo].[LocalAdmin_DefineGroup] t2
ON t2.machine_name LIKE '%'+t1.family_name+'%'