top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

How can I find the number of rows affected by a sql query?

0 votes
How can I find the number of rows affected by a sql query?
posted Jul 8, 2014 by Amanpreet Kaur

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

The function you will want, is mysql_affected_rows which you call after the query has run, and it will tell you how many rows were affected.

$qry="update table_name set column_3=somevalue where column_2=somevalue;

answer Jul 10, 2014 by Mohit Sharma
Similar Questions
0 votes

I have a number of INSERT and UPDATE statements in a MySQL Stored Procedure, that works in the form of START TRANSACTION followed by COMMIT. Also I am handling any EXCEPTION.

However, after calling COMMIT, how can I get the number of Rows that were affected either INSERTED or UPDATTED ?

+1 vote

What I want?

I want to display all the comments that are submitted on a particular post. Like if i have post number 2 and it has four comments so I want to retrieve all these 4 comments with the post.

Problem having?

The problem is that,whenever I try to retrieve the comments related the particular post, I get only one comment one post. But not all comments onto that post.

Query I have written :

SELECT zcomment.icomment, zpost.zpostbody, zcomment.myid, zcomment.myname, zpost.zpostid from zcomment LEFT JOIN zpost on zpost.zpostid=zcomment.myid

The above query only print the single comment and single post.

I have used Auto_Increment in zpostid so that whenever any post is submitted the value of it should be inserted into the table.
I have used primary key in zpostid and have made it foreign key in the zcomment table.(with the name myid).

Can anyone help me out with this,i am having this issue for a long time.

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.