Inner Join and Update with SQL Server & PHP -
Inner Join and Update with SQL Server & PHP -
i trying update 2 tables (requisition & stock) , subtract 2 column both table using inner bring together on sql server. i've tried , doesn't work out.
<?php $tsql = "update [mrs].[dbo].[requisition] inner bring together [mrs].[dbo].[stock] b on b.stockid = a.stockid set a.requeststatus = 'approved', a.approveddate = convert(varchar(10), getdate(),103), b.stockquantity = b.stockquantity - a.requestquantity requestid = '$_get[requestid]'"; $result = sqlsrv_query($conn, $tsql, array(), array ("scrollable" => sqlsrv_cursor_keyset)); header('location:approval.php'); ?>
you can't update multiple tables within single update
statement. way execute 2 separate update
statements within single transaction
begin transaction update set a.requeststatus = 'approved', a.approveddate = convert(varchar(10), getdate(),103) [mrs].[dbo].[requisition] requestid = $_get[requestid] update b set b.stockquantity = b.stockquantity - a.requestquantity [mrs].[dbo].[requisition] inner bring together [mrs].[dbo].[stock] b on b.stockid = a.stockid requestid = $_get[requestid] commit
php sql-server sql-update inner-join
Comments
Post a Comment