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 8976867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:14:34+00:00 2026-06-15T19:14:34+00:00

I have only just begun learning about joining tables in MySQL. Now, I have

  • 0

I have only just begun learning about joining tables in MySQL. Now, I have a small project where I simply want to let the visitor insert data through a form. The data is then displayed in a HTML table with four rows, joining together two tables in my database. The “problem” is that the data should be submitted into those two different tables in my database.

I tried

$query = "INSERT INTO table1, table2 (col1, col2, col3, col4) VALUES ('value1', 'value2', 'value3', 'value4')";

but that doesn’t seem to do it. What is the correct syntax for submitting form data to several database tables? Oh, and I read some similar threads mentioning using transactions. Is this necessary? My tables are run with MyISAM. Thanks!

  • 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-15T19:14:35+00:00Added an answer on June 15, 2026 at 7:14 pm

    You can read more about it from the MySQL Manual. In short, you cannot insert into multiple tables at once. This leaves you with three options:

    1. Multiple INSERT statements
    2. Triggers
    3. Stored Procedures

    The answer to this question: MySQL Insert into multiple tables? (Database normalization?) suggests using transactions, which will not work with MyISAM, but is a good FYI if you ever switch to InnoDB.

    I really recommend you read up on Triggers. They can make your life a lot easier. But if you don’t want to use them, look into PHP’s mysqli_multi_query, which will allow you to execute two different queries at the same time, for example:

    $query = "INSERT INTO table1 (col1,col2) VALUES ('$value1','$value2');";
    $query = "INSERT INTO table2 (col3,col4) VALUES ('$value3','$value4');";
    $result = mysqli_multi_query($dbcon, $query);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm reading about the State pattern. I have only just begun, so of course
I want to have the look of UITableViewCellStyleValue1 but instead of just only having
I have just become the only IT manager of a small business. We have
I have a FormCollection and I just want to only iterate through the keys
I have a dynamic list code that works just fine. My only problem now
I've recently begun a fairly small 2D project using SFML and TinyXML and have
I have just begun learning PostScript in order to produce graphics for LaTeX and
I have just begun with AJAX. I'm not sure about many things, though I
I've only begun tinkering with Go for about a week now, and am quite
I just learned (the hard way) that Java Component s can only have one

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.