Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2007
    Posts
    197

    Smile Unanswered: stored procedure to entry the count of table

    Hi ,
    Suppose I have table A I want to write stored procedure when the new
    entry in Table A , Its count entry should go in Table B

  2. #2
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    Quote Originally Posted by ankur02018
    Hi ,
    Suppose I have table A I want to write stored procedure when the new
    entry in Table A , Its count entry should go in Table B
    You could do this via a trigger ie when inserting a record into table A then just add one to the entry in the totals table (B). Even easier is to not use a table B at all and just use :
    Code:
    select count(*) from Table_A
    This is simpler, doesn't use any triggers and will never get out of sync. Performance may be an issue if you have millions or records in table A though.

    Mike

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    performance is not an issue for SELECT COUNT(*) queries made against a myisam table, no matter how big it is
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •