I'm wondering what is the most efficient way to obtain autocomplete results from multiple tables?
The caveat being; I want to be able to identify from what table the records are coming.
For example, given these example tables:
+- People
+- id
+- name
+- age
+- Places
+- id
+- name
+- distance
+- Things
+- id
+- name
+- color
While containing some data arbitrary to this issue, the main focus here is the name
columns (though these could be something else, or multiple per table being queried)
Anyways, I'm trying to figure out how to query each of these tables for data a' la autocomplete, and return the data and from what table it is. For example, the output for the letter A
may look something like this:
Apple (Things)
Amy (People)
Aaron (People)
Anaheim (Places)
Axe (Things)
Would this be best accomplished with a single query, or multiple queries across the various tables?
Thanks in advance :)