If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > stored procedure to entry the count of table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-18-09, 05:44
ankur02018 ankur02018 is offline
Registered User
 
Join Date: Jun 2007
Posts: 189
Smile 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
Reply With Quote
  #2 (permalink)  
Old 05-18-09, 05:58
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
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
Reply With Quote
  #3 (permalink)  
Old 05-18-09, 06:27
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
performance is not an issue for SELECT COUNT(*) queries made against a myisam table, no matter how big it is
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On