0

I have the following tables structure :

this table for main categories

enter image description here

for each category we can add values

enter image description here

for each category we can add filters for search

enter image description here

for each filter we can add values

enter image description here

finally this table is used for saving data to each category value this

enter image description here

I want to create search query to find results based on user chosen filter value

for example find a university that has sector : public and degree : bachelor?

the search will be done on the last table

for example find a university that has sector : public and degree : bachelor?

the query should handle filter_id = 1 and filter_id_value = 1 also filter_id =2 and filter_id_value =3

the final result should be university of jordan

NOTE : I program using php and mysql

Ala
  • 37
  • 2
  • 6
  • based on example : find a university that has sector : public and degree : bachelor SELECT * FROM tblname WHERE university like '%$unv%' and degree='bachlor' – Gopi Chand Apr 24 '17 at 10:19
  • I have edited the question to be more clear, I hope that you got the idea. – Ala Apr 25 '17 at 09:14

1 Answers1

0

please be more concrete about your issue. What is your current state? Did you do some approaches by yourself? We can't create the complete filter query for you. Please take a look at database relations, especially JOIN statements.

But i want to give you an approach. First, you have to determine in which kind your tables are related (1->1, 1->n, n->n ...). In your query, you have to connect your tables via JOINS and their ON statements (maybe you also could use USING statements, but this rely on your db concept). You can check in the WHERE condition if the user input match your records.

I hope you can continue your work with my help!

Community
  • 1
  • 1
T Schi
  • 116
  • 1
  • 6
  • the search will be done on the last table for example find a university that has sector : public and degree : bachelor? the query should handle filter_id = 1 and filter_id_value = 1 also filter_id =2 and filter_id_value =3 the final result should be university of jordan – Ala Apr 24 '17 at 11:44