Home > Database > Mysql Tutorial > body text

Mysql中的find_in_set的使用方法介绍_MySQL

WBOY
Release: 2016-06-01 13:23:59
Original
1154 people have browsed it

bitsCN.com

使用举例:

用户表(user)中的一个字段(purview)代表该用户的权限

将用户的所有权限id存入此字段。比如有:1,2,3,4,5这样的五个权限

查找哪些用户拥有权限id为1的权限


select * from user where find_in_set('1',purview);

sql语句

sql解释:查出所有拥有1这个权限的所有用户的信息。

这样设计数据表的目的是减少表的数量,但是会增加更新的难度!

bitsCN.com
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!