Previously: Select2 issues

Changed to: A strongly related SQL question. (Don't want to waste the bounty as I did not get an answer and my bounty is still open!)

Basically, I have 2 queries. One is general, and one is based on a search.

one: get everything (no issues here)

```
SELECT store_info.storeID, store_info.name, store_info.address, store_info.phone, GROUP_CONCAT(brands.name) AS brands
FROM store_info, brands, stores, store_brands
WHERE stores.city = $cityID
AND store_brands.store =  stores.ID
AND brands.id = store_brands.brand
AND stores.ID = store_info.storeID
GROUP BY store_info.storeID
ORDER BY store_info.name

```

This query does exactly what I want it to do. It gives me stores with the brands formatted as `brand1,brand2,brand3,brand4,brand5` etc.

Now, I also have a search function, where you can search for a store based on the brands. It's basically the same query with a small tweak **(issues here)**:

```
SELECT store_info.storeID, store_info.name, store_info.address, store_info.phone, GROUP_CONCAT(brands.name) AS brands
FROM store_info, brands, stores, store_brands
WHERE stores.city = $cityID 
AND store_brands.store =  stores.ID
AND brands.ID = store_brands.brand
AND stores.ID = store_info.storeID
AND brands.ID IN (" . implode(",", $brandIDs) . ")
GROUP BY store_info.storeID
ORDER BY store_info.name

```

The issue with this last query is that I still want it to return all the brands. I simply want to manipulate the brands that were searched for later on. The way I see it, I *should* be able to do it in multiple ways:

1 ) Return all the brands in the query and manipulate the brands when going through them in php (I have the search terms stored, but I don't know how to do this without getting all the stores, which is not something I want to do)

2 ) Return 1 field with the matching brands that were searched for, and another field with the remaining brands. (Ideal option, but I don't know how. Placing the entire query into a join with a tweak seems inefficient)

3 ) (Seems inefficient and I don't like it) get the found stores from the query, to run a new query looking for the brands related to the found stores, then combine the results with php. However, this would add an extra query and efficiency is priority.

I run into the issue that if someone searches for say, 2 brands, and there's stores that match with both, it will only show 1 of the 2 brands. (The first hit, I'm guessing).

Any help with this last query would very much be appreciated! 

Thanks in advance!

**Edit: a bit more insight into the search function**
The search function searches for stores that are related to the brands searched for. It should show the stores that are connected to said brands, but not limit itself to returning only the brands that were searched for.