I have a table to hold all my program settings and I am trying to figure out how to combine two queries as follows.
Here is table named `Config`.
Code:
------------------- Config Table ---------------------
|Setting | Param1 | Param2 | Param3 |
======================================================
|Access | Page1 | | ABCD |
|Access | Page2 | | D |
|Access | Page3 | | AD |
|Access | Page4 | | ABC |
|ServRoot| | | /MyServer/root/ |
|Menu | Page1 | php | The Main Page |
|Menu | Page2 | php | Photo Gallery |
|Menu | Page3 | php | Members Entrance |
|Menu | Page4 | htm | Some Static Page |
------------------------------------------------------
After the User logs in and is given an access level I want to build a custom menu.
- Using the 'Settings' table I check access rights for each page based on a predetermined acess level listed in 'Param3'.
If the
user access level is 'B' I would do:
Code:
"SELECT `Param1` FROM `Config` WHERE `Setting` = 'Access' AND `Param3` LIKE '%B%';"
- Then I recheck the 'Settings' table to get all the Menu items they have access to. I use the results from the first query to build a comma seperated string. The results from the first query woould build "('Page1','Page4')".
Code:
"SELECT * FROM `Config` WHERE `Setting`='Menu' AND `Param1` IN ('Page1','Page4');"
Code:
--------------------Result------------------------
|Setting | Param1 | Param2 | Param3 |
==================================================
|Menu | Page1 | php | The Main Page |
|Menu | Page4 | htm | Some Static Page |
--------------------------------------------------
How can I combine these queries to get the same result?