<p>Suppose that two tables exist: <code>users</code> and <code>groups</code>.</p>

<p><strong>How does one provide "simple search" in which a user enters text and results contain both users and groups whose names contain the text?</strong></p>

<p>The result of the search must distinguish between the two types.</p>

The trick is to combine a
```
UNION
```
with a literal string to determine the type of 'object' returned. In most (?) cases, UNION ALL will be more efficient, and should be used unless duplicates are required in the sub-queries. The following pattern should suffice:
```
```
SELECT "group" type, name
   FROM groups
  WHERE name LIKE "%$text%"
UNION ALL
 SELECT "user" type, name
   FROM users
  WHERE name LIKE "%$text%"
```
```
NOTE
: I've added the answer myself, because I came across this problem yesterday, couldn't find a good solution, and used this method. If someone has a better approach, please feel free to add it.