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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:01:42+00:00 2026-05-26T02:01:42+00:00

I am developing a web app using zend framework and the problem is about

  • 0

I am developing a web app using zend framework and the problem is about combining 2 sql queries for improving efficiency. My table structure is like this

>table message
id(int auto incr)
body(varchar)
time(datetime)

>table message_map
id(int auto incr)
message_id(forgain key from message table's id column)
sender(int ) comment 'user id of sender'
receiver(int) comment 'user id of receiver'

To get the code working, I am first inserting the message body and time to the message table and then using the last inserted id, I am inserting message sender and receiver to message_map table. Now what I want to do is to do this task in a single query as using one query will be more efficient. Is there any way to do so.

  • 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-26T02:01:42+00:00Added an answer on May 26, 2026 at 2:01 am

    No there isn’t. You can insert in only one table at once.

    But I can’t imagine you need to insert so much messages that performance really becomes an issue. Even with these separate statements, any database can easily insert thousands of records a minute.

    bulk inserts
    Of course, when inserting multiple records in the same table, that’s a different matter. This is indeed possible in MySQL and it will make your query a lot faster. It will give you trouble, though, if you need to insert_ids from all those records.

    mysql_insert_id() returns the first id that is inserted in the last insert statement, if it is a bulk insert. So you could query all id’s that are >= that id. It should give you all records you just inserted, although the result may contain id’s that other people inserted between your insert and the following query for those ids.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're developing a web app using the Zend framework and Mysql. Currently, accounts are
I am developing a web-app using zend framework. I like how all the autoloading
I'm developing a web app and currently using sql server 2008 for it. But,
I am developing a web app using the Joomla Framework. The jQuery UI accordion
I'm developing a web app on Yesod framework, using wai-handler-devel to run the server.
I am developing web app using Scala and Lift framework. I have record in
I've been developing an asp.net web app using VS studio. I'm using SQL Server
I'm developing a web-app and I'm using Spring framework. Thing is, i never properly
I'm developing a web app using the entity framework. I load a list of
I am developing a web app using servlets and jsps. I have a question

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.