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

  • Home
  • SEARCH
  • 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 1070537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:34:45+00:00 2026-05-16T20:34:45+00:00

im using mysql, these are two tables i have: posts {id, user_id, post, date}

  • 0

im using mysql, these are two tables i have:

posts {id, user_id, post, date}
post_tags {id, tag, post_id(references id in post), user_id}

what im trying to do is if the post has a #tag , i insert the intial post in the POSTS table, and the data in the post_tags table, how could i do that simlateanously?

P.S. i already know how to check if a post has a tag!! i just want to undertand, how can insert data into both!! espcially the ID’s because they are generated within mysql(autoincrement)!!

  • 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-05-16T20:34:45+00:00Added an answer on May 16, 2026 at 8:34 pm

    You can seperate these two queries and run them after each other. You can use mysql_insert_id() for the last inserted id in an table.

    $query = "INSERT INTO posts (id, user_id, post, date)
        VALUES (id, user_id, post, date)";
    mysql_query($query) or die(mysql_error().$query); // run query
    
    $lastid = mysql_insert_id(); // this will get the last inserted id.
    
    $query = "INSERT INTO post_tags (id, tag, post_id, user_id)
        VALUES (id, tag, ".$lastid.", user_id)";
    mysql_query($query) or die(mysql_error().$query); // run query
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to these types of MySQL Queries. Basically, I have two tables in
I have these two tables in MySql: [Person] PersonId NameFirst NameLast [Email] EmailId PersonId
Possible Duplicate: mysql is array in multiple columns I have two tables: Posts Table
I have a database using MySQL 2005. I have two tables, Enrolment and AlertMsg.
I am trying to create a calculation logic using MySQL tables. Data from two
I have a list of dates stored in MySQL using PHP. These were stored
I'm using MySQL 4.2. I have 2 tables: tbl_User stores USERID and REGCODE. REGCODE
I have tried using a combination of both of these two previous questions Question
Consider these two tables stored in a MySQL database. The first stores a list
Right now I have two tables for getting a timeline of posts that a

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.