Questions tagged [rows-affected]

The number of rows affected by executing a SQL Query

The number of rows affected by executing a SQL Query.

The @@ROWCOUNT variable will return the number of rows affected by the last executed query in SQL Server

65 questions
1
vote
3 answers

Cache-Control messing with mysqli->affected_rows

I have one webpage (lets call it A.html). A.html has some javascript which switches the page to a dynamic php page (lets call it B.php), using a simple document.location="B.php". B.php runs a mysql query based on the cookies it sees, and returns a…
Mediocre Gopher
  • 2,274
  • 1
  • 22
  • 39
1
vote
1 answer

PHP sql_srv_rows_affected to return multiple outputs

I have created a stored procedure to import a list of records. This stored procedure INSERTs to a temporary table then MERGEs based on if contract numbers match. WHEN NOT MATCHED BY TARGET it INSERTs into the real table and WHEN NOT MATCHED BY…
NickC217
  • 216
  • 2
  • 6
  • 14
1
vote
1 answer

How to get count of affected row in T-SQL

I have an stored procedure with below body: ALTER PROCEDURE dbo.sp_DeleteRoecords @Conditions NVARCHAR(200) AS BEGIN DECLARE @Query NVARCHAR(2000) SET @Query = 'DELETE FROM Customer Where ' + @Conditions EXEC (@Query) END How I…
user4756993
1
vote
1 answer

CDbCommand::createCommand() returns zero affected rows inside migration

This code works just fine (all database items updated as expected): foreach($idMap as $menuId=>$pageId) { $sql = "UPDATE `menus_items` SET link = '/content/show?id=".$pageId."' WHERE id = ".$menuId."; "; $affectedRows =…
trejder
  • 17,148
  • 27
  • 124
  • 216
1
vote
4 answers

How to determine if MySQL UPDATE actually matched any rows with WHERE clause?

I want to run an update like such in PHP // pseudocode UPDATE invoice SET due_date=? WHERE invoice_id=? AND creater_id=?; IF AFFECTED_ROWS == 1 THEN UPDATE invoice_item SET price=? WHERE invoice_id=? For added security, I appended creater_id to…
Jake
  • 11,273
  • 21
  • 90
  • 147
1
vote
0 answers

SQL Server, trigger changes rows affected

We have an issue in our database with some rows that have disappeared, so we would like to create an on deleted trigger. Creating the trigger isn't a problem. The problem is that the rows affected is changed from 1 to 2 whenever we delete a line…
Louisa
  • 552
  • 1
  • 9
  • 22
1
vote
1 answer

PHP mysqli affected_rows method seems to have a bug

I'm getting an odd result, the following is the state of the mysqli object after a simple update query: "UPDATE charstate SET name = '-', type = 'The Homemaker' WHERE gameno = 1" As you see the affected_rows = -1 but... the info is "Rows matched: 3…
iss42
  • 2,720
  • 3
  • 21
  • 37
0
votes
1 answer

show the affected rows after update/insert/delete in DB2

hello I used to work with Postgres and there if I want to see the affected rows after a manipulation I used the key word RETURNING Example to show all the columns of the affected row(s): UPDATE tblName SET colName='something' WHERE…
Abra
  • 19
  • 3
0
votes
1 answer

When I do an update with inner joins, changing the clause ON columns affects the update?

For example if you have this query: UPDATE table1 INNER JOIN table2 ON table1.id = table2.id SET table2.id = table1.idSetting WHERE table2.property IS NULL You can note that the table2 id's changes when the table2.property is null, my question…
0
votes
1 answer

Check Whether Particular query from multiple query is affected or not

Let Suppose i have Following code which updates two different table if(isset($_POST['submit'])){ $updateq = $conn->query("UPDATE `tbl1` SET `field1`= '$field1'"); $updater = $conn->query("UPDATE `tbl2` SET field2 ='$field2'"); //Here…
TarangP
  • 2,711
  • 5
  • 20
  • 41
0
votes
0 answers

PHP and MYSQL check for update "error"

While editing a mysql database row, I normally like to check if the action was successful before I redirect my user. Normally I use the following: $result = mysqli_query($connection, $queryu); if (mysqli_affected_rows($connection) == 1) { //…
0
votes
1 answer

Update row count in php mysqli not working when updating multiple query

Following is my code //FIRST UPDATE QUERY $firstupdatequery = "UPDATE `register` SET suser ='1' "; //Second UPDATE QUERY $updater = "UPDATE `register` SET suser ='$suser',steamleader ='$steamleader',ipdate ='$ipdate',customer ='$customer',cperson1…
user9341437
0
votes
1 answer

That update query doesn't work?

Hello boys and girls :) I have that query: SELECT * FROM customer INNER JOIN address ON customer.customer_id = address.customer_id WHERE address.country_id = 176 So i want to update custome.status to 0 I tried with that query but "0 rows…
MorganFreeFarm
  • 3,811
  • 8
  • 23
  • 46
0
votes
1 answer

How to know affected rows using DB Transaction?

$this->db->trans_start(); $obj = array( 'id_supplier'=>$idsupplier, 'nama_cp'=>$namacp, 'email'=>$email, 'note'=>$note ); …
TA Fighting
  • 23
  • 1
  • 4
0
votes
0 answers

SQL, show affected and non affected rows

Is there a way to show/return affected AND non-affected rows when I am doing a LEFT JOIN in SQL Server? The code below currently only returns affected rows. For example: SELECT a.*, b.cost INTO Cost_Report_2016 FROM Cost_Report_2017…
spacedustpi
  • 351
  • 5
  • 18