【发布时间】:2012-04-13 05:59:42
【问题描述】:
我不熟悉这种关系类型的数据库设计。我只是以这种方式设计了数据库。但是,我对 MySQL 的 JOIN 感到很困惑。加入所有这张表的查询应该是什么。如果你能看到表users是所有表的引用。
用户
+----------+----------------+-----------------+
| users_id | users_level_id | users_status_id |
+----------+----------------+-----------------+
| 1 | 1 | 1 |
| 2 | 2 | 1 |
+----------+----------------+-----------------+
users_credentials
+----------+---------------------------+-----------------------------+----------------------------+
| users_id | users_credential_username | users_credential_email | users_credential_password |
+----------+---------------------------+-----------------------------+----------------------------+
| 1 | super | super@gmail.com | $5$e94e9e$vptscyHjm8rdX0j6 |
| 2 | admin | admin@gmail.com | $5$fVuOmySyC0PttbiMn8in0k7 |
+----------+---------------------------+-----------------------------+----------------------------+
users_level
+----------------+-------------------------+
| users_level_id | users_level_description |
+----------------+-------------------------+
| 1 | Super Administrator |
| 2 | Administrator |
+----------------+-------------------------+
用户状态
+-----------------+--------------------------+
| users_status_id | users_status_description |
+-----------------+--------------------------+
| 0 | Disabled |
| 1 | Enabled |
+-----------------+--------------------------+
【问题讨论】:
-
如果您不熟悉 SQL 中的
JOINs,请阅读几篇关于它们的文章。两个建议:codinghorror.com/blog/2007/10/… 和 en.wikipedia.org/wiki/Join_(SQL)
标签: mysql join inner-join