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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:56:22+00:00 2026-06-01T13:56:22+00:00

I’m implementing a book search function based on authors. I should return a query

  • 0

I’m implementing a book search function based on authors. I should return a query result that contains all the books written by the queried author. However, it is possible that a query for certain author names returns multiple results (e.g., a query of “Smith, W” might match “Smith, Wesson” and “Smith, Will”).

So, my problem is how to “concatenate” all the books written by these different authors. If I don’t consider the possibility of multiple authors matching a query, I’d go about something like this (in pseudocode, as my real code is quite messy right now):

  • search author table for the author
  • matching the query
  • get author’s authorid
  • search book table for book records with the same authorid

However, with the possibility of multiple authors, I have something like this in mind:

// search author table for authors matching the query

foreach(author_match as am){
  // search book table for book records with authorid=am.authorid
  // Is there such thing as this? :\
  book_results += all the rows returned by previous query
}
return book_results;

I’m doing this in PHP (with CodeIgniter Framework) and MySQL. Is there any function/operator that will allow me to do this? Yes, I’ve tried +=, even if I wasn’t expecting much from it, to an ugly output.

Again, my apologies for the pseudocode. I’ll try to clean-up my code and edit ASAP but if an answer comes before that, it’d be just as awesome. Thanks.

  • 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-01T13:56:23+00:00Added an answer on June 1, 2026 at 1:56 pm

    I agree with Michael, it seems you need either an INNER JOIN or a LEFT JOIN.

    You say you are using Codeigniter so here is a Codeigniter specific example:

    $this->db->select('author.*, 
                       book.*');
    $this->db->from('authors');
    $this->db->join('books', 'books.authorid = authors.id', 'left');
    $this->db->where('authors.id', $the_author_id);
    

    Also see:

    • Codeigniter’s Activerecord documentation
    • Other Codeigniter JOIN questions on SO
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

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.