Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to "concatenate" results of a query?
    text
    copied!<p>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").</p> <p>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):</p> <ul> <li>search author table for the author </li> <li>matching the query</li> <li>get author's authorid</li> <li>search book table for book records with the same authorid</li> </ul> <p>However, with the possibility of multiple authors, I have something like this in mind:</p> <pre><code>// 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; </code></pre> <p>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 <code>+=</code>, even if I wasn't expecting much from it, to an ugly output.</p> <p>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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload