php - SQL join table in array fields -
is real select data multiple tables inner join
and put in array field? example have tables users, user_details, user_clients
table users
have next columns: [id, login, password]
table user_details
have: [first_name, last_name, profile_pic, fk_userid]
and table user_clients
contains information clients belong user: [client_name, client_phone, client_address, fk_userid]
one user can have many clients user_clients
.
so can data next sql queryes:
$usergeneraldata = $db->query("select * users inner join user_details on(users.id = user_details) users.id = 13");
and query user clients array
$arruserclients = $db->query("select * user_clients fk_userid=13");
but can same, 1 query? clean output without duplication , array field of user_clients
?
if i'll use typical inner join
user_clients duplication data, this:
[0] => array ( [id] => 13 [login] => rob [password] => 123 [first_name] => robert [last_name] => frido [profile_pic] => picture_1.png [client_name] => andrew [client_phone] => +371 13243 [client_address] => street 1 [fk_userid] => 13 ) [1] => array ( [id] => 13 [login] => rob [password] => 123 [first_name] => robert [last_name] => frido [profile_pic] => picture_1.png [client_name] => martin [client_phone] => +422 1423423 [client_address] => london [fk_userid] => 13 )
so, main information user duplicates in each array, , changed client information.
i wanted put information client, field array, (i dont sure it's real do):
array ( [id] => 13 [login] => rob [password] => 123 [first_name] => robert [last_name] => frido [profile_pic] => picture_1.png [arr_clients] => [0] => array ( [client_name] => anrew [client_phone] => +371 13243 [client_address] => street 1 [fk_userid] => 13 ) [1] => array ( [client_name] => martin [client_phone] => +422 1423423 [client_address] => london [fk_userid] => 13 ) )
Comments
Post a Comment