Php 比较两个MySQL表以筛选结果
我有一个MySQL数据库,其结构如下: 表1Php 比较两个MySQL表以筛选结果,php,mysql,comparison,Php,Mysql,Comparison,我有一个MySQL数据库,其结构如下: 表1 UniqueID | TitleID | DescriptionID | ContentRating ------------------------------------------------------ 1 | Hello | I Am Text | Universal 2 | Again | Yet More Text | Universal 3 | This | Yet Mo
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
- UniqueID(int)(主键和自动递增)
- TitleID(varchar)
- DescriptionID(varchar)
- 内容分级(varchar)
- UID(int)(主键和自动递增)
- 活动(varchar)
- ContentLimit(varchar)
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
表2
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
如果“Felix Tiger”登录,那么他将能够看到任何提交的带有“家长指导”评级的内容以及带有“通用”评级的内容
但如果“Jane Smith”登录,则她只能查看提交的任何具有“通用”评级的内容
我道歉,如果我不清楚,并将明确任何可能是误读或难以理解
提前感谢您提供的任何帮助。试试这个:
SELECT
a.*,
b.*
FROM table1 a
JOIN table2 b ON a.ContentRating = b.ContentLimit
试试这个:
SELECT
a.*,
b.*
FROM table1 a
JOIN table2 b ON a.ContentRating = b.ContentLimit
你为什么不使用一个现有的authz模块呢?为什么不使用一个现有的authz模块呢?非常感谢,Eduard7,我被这个问题难住了一个小时,然后决定在这里提问,我很高兴我这么做了。真不敢相信事情竟如此简单。再次感谢。非常感谢,爱德华兹,我被这件事难住了一个小时,然后决定在这里问,我很高兴我问了。真不敢相信事情竟如此简单。再次感谢。