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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:02:28+00:00 2026-05-25T23:02:28+00:00

I am trying to create a many-many relationship between the max(id) in table1 with

  • 0

I am trying to create a many-many relationship between the max(id) in table1 with all the ids in table2, using a lookup table called table1_table2.

Ultimately so that the rows in table1_table2 will be:

table1_id, table2_id
30, 1
30, 2
30, 3
...
30, 10000

How can I do this?

I have tried

insert into insert into table1_table2 (table1_id, table2_id) 
   values (select max(id) from table2, select id from table3); 

and

insert into insert into table1_table2 (table1_id, table2_id) 
   select max(table1_id), table2_id from table1 
      join table1_table2 on table1_table2.table1_id = table1.id 
      outer join table1_table2 on table1_table2.table2_id = table2.id; 

But neither seem to work

  • 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-25T23:02:29+00:00Added an answer on May 25, 2026 at 11:02 pm

    It sounds like this is what you want:

    INSERT INTO table1_table2 (table1_id, table2_id) 
        SELECT MAX(table1.id), table2.id FROM table1, table2 GROUP BY table2.id;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a many-to-many relationship using EF code first in my MVC
I am trying to create a many to many relationship between 2 tables. I've
I'm trying to define a simple one-to-many relationship between two poco's , using the
I am trying to have a many to many relationship between players and fixtures.
I'm trying to write a route that captures the one-to-many relationship between posts and
I'm trying to create a many-to-many association between an entity and another many-to-many association.
I'm trying to decide whether to create many classes for each content type I
I am trying to create a form with many groups containing many radio buttons.
I'm trying to create proper header files which don't include too many other files
I've implemented horizontal page view with many images. And I'm trying to create 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.