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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:30:16+00:00 2026-06-17T04:30:16+00:00

I have 3 tables one is called subscribers, one users, and one is called

  • 0

I have 3 tables one is called subscribers, one users, and one is called blogs. They each look as followed.

CREATE TABLE IF NOT EXISTS `subscribers` (
   `user_id` int(11) NOT NULL,
   `blog_id` int(11) NOT NULL,
);

CREATE TABLE IF NOT EXISTS `users` (
    `id` int(11) NOT NULL,
    `name` varchar(255)
);

CREATE TABLE IF NOT EXISTS `blogs` (
    `id` int(11) NOT NULL,
    `name` varchar(255),
    `user_id` int(11)
);

I have a situation where an API creates blog records in our db automatically, these automatically created blogs are all assigned the same user id (in this case 123) so that it is known that they really come from and belong to the importing API. Now after the fact a user needs to be created for these API originating blogs to look after them. I created user 123 using basic inserting, but now I must subscribe this user to every blog that they own via an insert or a series of inserts. I want to know if it is possible to do this with one query. Something like this, but I realize what I wrote will not work:

INSERT INTO `subscribers` (`user_id`,`blog_id`) 
VALUES 
(123, (SELECT id FROM `blogs` WHERE `user_id` = 123));

Is it possible to do a multi-insert based on a variable number of rows in some way, I have researched and I cannot find an answer yet. Thank you for your help.

  • 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-17T04:30:18+00:00Added an answer on June 17, 2026 at 4:30 am

    This is how to do it:

    INSERT INTO `subscribers` (`user_id`,`blog_id`) 
       SELECT 123, id FROM `blogs` WHERE `user_id` = 123;
    

    or even

    INSERT INTO `subscribers` (`user_id`,`blog_id`) 
       SELECT user_id, id FROM `blogs` WHERE `user_id` = 123;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables, one called Events and one called Documents. Each table has
I have 2 mysql tables one called 'users' and another called 'connections' Table users
I have 2 tables, one called products and one images. The table images hold
So I have two tables, one called 'questions' and one called 'tests'. Each row
I have two tables, one called Users and one called Groups . I also
I have 2 tables. One called users & the other called tv shows. The
I have 2 tables, one called posts and one called users . Inside posts
I have two tables, one called episodes, and one called score. The episode table
I have 2 tables. Table A has just one column called ID which has
I have two tables, one called Players and one called Awards. End-users give an

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.