user - How to have multiple values in phpmyadmin column? -
i know how have multiple values in column row. in case, multiple access numbers users can retrieve numbers page access.
what have now:
--------------------------------------------------------------------------------- id | first_name | last_name | email | password | date | access | --------------------------------------------------------------------------------- 1 | test | user | test@website.com | md5pass | -date- | 2 ---------------------------------------------------------------------------------
i give user multiple access codes/variables/integers.
like this:
--------------------------------------------------------------------------------- id | first_name | last_name | email | password | date | access | --------------------------------------------------------------------------------- 1 | test | user | test@website.com | md5pass | -date- | 2, 201, 3908 ---------------------------------------------------------------------------------
is possible??
and upon retrieving it, if possible, how go that?
i plan on doing like: if user access code '201' exists, give access/show content.
the way you're going can work; explode , trim access
column out when retrieve user row.
however, right way have different table, user_access. @ simplest, that'd like:
create table user_access ( user_id int, access int )
this table have 1 row per access code defined, per user. here's example in table:
select * user_access; +---------+--------+ | user_id | access | +---------+--------+ | 1 | 2 | | 1 | 201 | | 1 | 3908 | +---------+--------+
then, when retrieve user , you're interested in access level, you'd join against user_access table:
select u.*, ua.access users u left join user_access ua on u.id = ua.user_id u.id = <some user id>
(left join, because there's no guarantee user has access defined)
or, in 2 queries:
select * users id = <some user id> select access user_access user_id = <some user id>
Comments
Post a Comment