从3个表中获取数据 [英] Get Data from 3 tables
本文介绍了从3个表中获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚开始我的第一个php和mysql项目并且必须获取查询,
i有以下表格
I just starting my first php and mysql project and have to fetch queries,
i have following tables
User(user_id, user_name, password)
permissions (permission_id, permission_type)
user_permission (id, user_id, permission_id)
User to user_permission与user_permission的权限之间存在一对多的关系。
我需要在单个查询中获取针对user_name和password的权限类型吗?
there is a relationship of One to many of User to user_permission and permissions to user_permission.
I need to get permission type of against user_name and password in a single query?
推荐答案
您将使用内部联接作为MySQLi语句并使用准备构建它PHP语句。阅读:
1. MySQL INNER JOIN [ ^ ]
2. PHP和MySQLi中的准备语句 [ ^ ]
You will use inner join for the MySQLi statement and construct it using prepared statement in PHP. Read up:
1. MySQL INNER JOIN[^]
2. Prepared Statements in PHP and MySQLi[^]
这篇关于从3个表中获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文