Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8296243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:55:04+00:00 2026-06-08T14:55:04+00:00

Currently when a new row is inserted into my users table I have 1

  • 0

Currently when a new row is inserted into my users table I have 1 row inserted into each of these other tables respectively:

profiles
user_settings
user_activity

Currently I’m doing if from the PHP:

$query = mysql_query('INSERT INTO `users` blah blah...');

if($query) {
   mysql_query('INSERT INTO `profiles` blah blah...');
   mysql_query('INSERT INTO `user_settings` blah blah...');
   mysql_query('INSERT INTO `user_activity` blah blah...');
}

How can this be done via stored procedures? So that this work will be done by the database server and not the PHP code. Also is there any benefits to doing this from stored procedures vs from code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T14:55:06+00:00Added an answer on June 8, 2026 at 2:55 pm

    I think what you are looking for are triggers not stored procedures. With triggers you can execute a query after or before an insert/update/delete query.

    http://dev.mysql.com/doc/refman/5.1/en/create-trigger.html

    Advantages: It is stored and invoked directly in the DB and I suppose it is more performant as well.

    Example:

    CREATE TRIGGER mytrigger AFTER INSERT ON users
       FOR EACH ROW BEGIN
          INSERT INTO `profiles` blah blah...;
          INSERT INTO `user_settings` blah blah...;
          INSERT INTO `user_activity` blah blah...;
    END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently using a MySQL database Wanting to insert a new row into a table
I have a table where each row needs a timestamp marking the time it
I have a table which stores records which require to be inserted into another
Using Doctrine DBAL, I have some code that inserts a new row into the
I'm currently new into client-side programming, especially using the Jquery Ajax method to call
I am new to JPA/Hibernate. Currently using EJB3, Hibernate/JPA. I have an inheritacnce structure
SQL 2005, 600,000,000 rows. I have a table called Location currently using the data
I have a 'People' table with several attributes including 'age'. Each time I insert
Currently looking to extract data from 2 tables and insert into another. Tables as
I have a trigger that sets a datetime field in a table row when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.