mysql - retrieving information from 3 tables -


i have 3 tables:

users: +----------+-----------------------------+-----------+ | users_id | user detail                 | otherid   |  +----------+-----------------------------+-----------+ |        1 | user name or details        |         1 | |        2 | user name or details        |         1 | |        3 | user name or details        |         4 | |        4 | user name or details        |         1 | |        5 | user name or details        |       21  | |        6 | user name or details        |         2 | +----------+-----------------------------+-----------+ photos: +----------+----------------+-----------+--------+---------+--------------+ | photosid | url            |    title  | userid | likes   | remarksid    | +----------+----------------+-----------+--------+---------+--------------+ |      1   |       7459.jpg |   title   |      1 |     150 |       255    | |      2   |       7510.jpg |   title   |      1 |     146 |       247    | |      3   |       7460.jpg |   title   |      2 |       2 |        56    | +----------+----------------+-----------+--------+---------+--------------+  remarks: +-----------+---------------------------------------+---------+------------+ | remarksid | remark                                | userid  | photoid    | +-----------+---------------------------------------+---------+------------+ |         1 | remarks photoid 1                 |       1 |          1 | |         2 | remarks photoid 1                 |       1 |          1 | |         3 | remarks photoid 1                 |       1 |          1 | |         4 | remarks photoid 2                 |       1 |          2 | |         5 | remarks photoid 2                 |       1 |          2 | |         6 | remarks photoid 3                 |       2 |          3 | +-----------+---------------------------------------+---------+------------+ 

i trying extract remarks given users photo, want photo appear once relevant remarks photo displayed each users photo. if there no remarks display photo without remarks.

the layout on web page-

------------------------------------ photograph 1          remarks 1          remarks 2          remarks 1 ------------------------------------ photograph 2          no remarks photo ------------------------------------ photograph 3          remarks 1          remarks 2          remarks 3          remarks 4 ------------------------------------ photograph 4          remarks 1          remarks 2 ------------------------------------ 

is assumption correct difficulty is, how database this? if so, answer function (formatting data), not (or should not) responsibility of database. fetch photos database 1 result set, fetch matching comments in another, , let application or reporting tool format data way want it.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -