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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:07:51+00:00 2026-05-30T20:07:51+00:00

I have a table like: called BOOKS +——+——————-+—————+ | id | book_title | author

  • 0

I have a table like: called BOOKS

+------+-------------------+---------------+
| id   |  book_title       |  author       |
+------+-------------------+---------------+
| 1    |  learning mysql   |  1234 12      |
+------+-------------------+---------------+
| 2    |  learning php     |  125 50       |
+------+-------------------+---------------+

And i want a VIEW from BOOKS and AUTHOR:

+------+-------------------+  
| id   |  author           |
+------+-------------------+
| 12   |  JOHN             |
+------+-------------------+
| 50   |  PAUL             |
+------+-------------------+
| 125  |  CHRISTOPHER      |
+------+-------------------+
| 1234 |  PATRICK          |
+------+-------------------+

So that i can have a VIEW which i should be something like the table which is below but should show instead of author id author name from tabel AUTHOR.

+------+-------------------+-----------------------------------+
| id   |  book_title       |  author                           |
+------+-------------------+-----------------------------------+
| 1    |  learning mysql   |  PATRICK                          |
+------+-------------------+-----------------------------------+
| 1    |  learning mysql   |  CHRISTOPHER                      |
+------+-------------------+-----------------------------------+
| 2    |  learning php     |  JOHN                             |
+------+-------------------+-----------------------------------+
| 2    |  learning php     |  PAUL                             |
+------+-------------------+-----------------------------------+
  • 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-30T20:07:52+00:00Added an answer on May 30, 2026 at 8:07 pm

    Your database design is wrong. books.author should be INT and contain foreign key to author.id. Table author should contain name VARCHAR(255) (or two columns referencing to author_name, I’m still not sure whether you have two authors or you split name into 2 entries).

    So correct design would be:

    BOOKS (
      id INT,
      book_title VARCHAR(255),
      author INT, -- only if each book has just one author
      PRIMARY KEY (id)
    )
    
    AUTHOR (
      id INT,
      name VARCHAR(255),
      first_name_id INT, -- If you want to split names into more columns
      PRIMARY KEY (id)
    )
    
    -- If you need more authors for one book
    -- you maybe should keep original (primary) author id
    BOOK_AUTHOR (
      book_id INT,
      author_id INT,
      PRIMARY KEY (book_id, author_id)
    );
    

    Than you may select data with:

    SELECT BOOKS.id, BOOKS.book_title, AUTHOR.name AS author
    FROM BOOKS
    -- Study difference between left and inner joins
    INNER JOIN AUTHOR on AUTHOR.id = BOOKS.author
    

    And if you need to have more authors for one book:

    SELECT BOOKS.id, BOOKS.book_title, AUTHOR.name AS author
    FROM BOOKS
    LEFT JOIN BOOK_AUTHOR on BOOK_AUTHOR.book_id = BOOKS.id
    LEFT JOIN AUTHOR on AUTHOR.id = BOOK_AUTHOR.author_id
    

    And you may need to output authors as Wolfgang Goethe; Oscar Wilde, than you can use GROUP_CONCAT:

    SELECT BOOKS.id, BOOKS.book_title,
           GROUP_CONCAT( AUTHOR.name SEPARATOR '; ') AS author
    FROM BOOKS
    LEFT JOIN BOOK_AUTHOR on BOOK_AUTHOR.book_id = BOOKS.id
    LEFT JOIN AUTHOR on AUTHOR.id = BOOK_AUTHOR.author_id
    GROUP BY BOOKS.id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this mysql table called comments which looks like this: commentID parentID type
If I have table with a Date column called myDate , with values like
I have SQL Server 2008 with a table called ProductCategories designed like this: Id
I have a sql table called UsersInAuthentication like ----------------------- | AuthUserId | UserId |
I have a table (in MySQL) called unused with about 5.4 million rows. The
Let's say I have a table called my_table that looks like this: id |
i have a table called users this what the table look like CREATE TABLE
I have a MySQL database called bookfeather. It contains 56 tables. Each table has
If I have table like this called table +--------------+ | id | c1 |
I have one sql table that looks like this called posts: id | user

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.