Does anyone know if it's possible to turn something like the table below.. While still being able to use a SELECT query.
+----+-----------+---------------+------------+
| id | listingId | value | identifier |
+----+-----------+---------------+------------+
| 1 | 1a | Alaskan Husky | race |
| 2 | 1a | High | activity |
| 3 | 1a | White | colour |
| 4 | 1b | Akita | race |
| 5 | 1b | Medium | activty |
| 6 | 1b | Grey | colour |
+----+-----------+---------------+------------+
To something like this, while still being able to use a select query..
+----+-----------+---------------+---------+--------+
| id | listingId | race | activty | colour |
+----+-----------+---------------+---------+--------+
| 1 | 1a | Alaskan Husky | High | White |
| 2 | 1b | Akita | Medium | Grey |
+----+-----------+---------------+---------+--------+
I also want to be able to search this new "table". Let's say, the user has picked a filter with something like this:
- Race: Alaskan Husky
- Activity: Medium, High
It should then return the listingId of 1a.
The reason being for this, is that I can't do a proper SELECT query, when all the values are placed in different rows..
As you can see, the listingId should be the variable that groups it all together, and makes the value in the identifier column, a new column.
The reason why I don't just use the second table as default, is because each listing can have different filters and filter groups. And I need to be able to select specific listings that meet a user specified filter.
Thanks.