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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:35:37+00:00 2026-05-23T07:35:37+00:00

I would be really grateful if somebody could help me out with this.. I

  • 0

I would be really grateful if somebody could help me out with this..

I actually have 2 tables in my database: books and authorlist.

The book table contains a field ‘book_aut‘ which contains the foreign key of the authorlist table.

The authorlist table has only 2 fields, the primary key and the ‘authors’ column which contains a list of names.

I have to modify the table structure so that books table is linked to an authors table via a link table called ‘lnk_book_author‘

So my first task is to create a new table called ‘authors’ which contains 3 fields – primary id, name, surname, which i already did.

Next, i created the link table called ‘lnk_book_author‘ and this one contains 3 fields, the primary id, book_fk, author_fk. The book_fk and author_fk refer to the id of the book and author respectively.

My problem is that i have more than 6000 entries in the books table and i would like to know how to populate the link table with the book id and the author id.

Is there a way of doing that using sql instead of manually populating the lnk_book_author table.

Hope i was clear enough..

Thanks a lot for any suggestion provided.

  • 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-23T07:35:37+00:00Added an answer on May 23, 2026 at 7:35 am

    I’m infering the IDs already in your new [authors] table mean nothing with regards to the old tables. If that’s the case you need to relate the records by the Name. And there I need to assume that the names are entered Identically. If they’re not, it may not be possible to do. We’d need to know a lot more specifics to be sure…

    INSERT INTO
      lnk_book_author
    SELECT
      Books.PrimaryKeyFieldName,
      Authors.PrimaryKeyFieldName
    FROM
      Books
    INNER JOIN
      AuthorList
        ON Books.BookAut = AuthorList.PrimaryKeyFieldName
    INNER JOIN
      Authors
        ON CONCAT(',', AuthorList.Authors, ',') LIKE CONCAT('%,', Authors.Name, ',%')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would be really grateful if someone could shed some light on this for
I have this array which is retrieved by a json_encode().When I execute $.getJSON('beta.php' ,
I have 2 models - batch and submision. Batch has_many :submissions Submission belongs_to :batch
Ok, this may seem like a dupe question, but if you bear with me
I have in my rails form the following code: <label>Fruit: </label> <%= f.select(:IST_FRUIT, [['Apple',
I have a challenging problem I've been battling for some time now. The Problem:
I'm working on a program that uses HTML/CSS/Javascript/JQuery for its user interface. One of
I'm currently doing some redesign of a website, basically just upgrading it to a
I'm writing a Java program and need to analyze small chunks of text (3-4
I am trying to access addresses such as 50526 on a Socomec Diris A40

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.