I have a MySQL database with the following structure:
Table1
- UniqueID (int) (PrimaryKey & AutoIncrement)
- TitleID (varchar)
- DescriptionID (varchar)
- ContentRating (varchar)
Table2
- UID (int) (PrimaryKey & AutoIncrement)
- Activity (varchar)
- ContentLimit (varchar)
What I want to do is take the value from ContentLimit (in Table2) and compare it against (ContentRating) in Table1, if they match then show all the rows that match. I’m using PHP and MySQL to achieve this.
Below is an Example:
Table1
UniqueID | TitleID | DescriptionID | ContentRating
------------------------------------------------------
1 | Hello | I Am Text | Universal
2 | Again | Yet More Text | Universal
3 | This | Yet More Text | Universal
4 | Is | Yet More Text | Parental Guidance
5 | Some | Yet More Text | Universal
6 | Dummy | Yet More Text | Parental Guidance
7 | Text | Yet More Text | Parental Guidance
8 | I | Yet More Text | Parental Guidance
9 | Think | Yet More Text | Parental Guidance
Table2
UID | Name | Activity | ContentLimit
---------------------------------------------
1 | John Smith | IsActive | Universal
2 | Jane Smith | IsActive | Universal
3 | Felix Tiger | IsActive | Parental Guidance
4 | Spring Load | InActive | Universal
If “Felix Tiger” was logged in then he would be able to see anything submitted with a “Parental Guidance” rating as well as anything with a “Universal” Rating.
But If “Jane Smith” was logged in then she would only be able to view anything submitted with a “Universal” rating
I apologise if I am unclear and will make clear anything that may be mis-read or hard to understand.
Thank you in advance for any help given.
Try this: