I had unique requirement. I Don't know it's my table structure problem or some thing else, but I need a solution for my output either structure change or query change.
I had a table which are containing a dynamic values of two fields of a single user. A single user can have multiple records of that types.
Example tables below
Table Name: tbl_parameters
parameter_id parameter_name
1 Current Location
2 Booked Location
3 Room Type
Table Name: tbl_paramter_data
id(auto_increment) user_id parameter_id parameter_value
1 10 1 Hyderabad
2 10 2 Delhi
3 10 3 Deluxe Room
4 11 1 Hyderabad
5 11 2 Bombay
6 11 3 A/C Room
7 12 1 Delhi
8 12 2 Bombay
9 12 3 Deluxe Room
10 13 1 Hyderabad
11 13 2 Delhi
12 13 3 Single Room
The above is my two tables. Its a Hotel Booking table. A user can book a hotel room any where from India. So, I stored in 2 different table. 1st table will contain what type of parameters I need to store with a parameter_id. The 2nd table contain the parameters values of each user From Where they are booked, which room they booked and remaining data. there are some other parameters also. **The No of parameters are dynamic. There are not a fixed no of parameters, that's the reason I maintained a separate table as tbl_parameters.
My Question is How can I get the data of
- Who are the users Booked the Rooms from "Hyderabad" in "Bombay" Hotel?
- Who are the users Booked the "Deluxe Rooms" from "Delhi" in "Bombay" Hotel?
How do I write a query to fetch the above data from the existing table(tbl_parameter_data)?
Or Shall I need to change the table structure or the way we are storing?