MySQL查中间5个数据_MySQL查询从5个表中获取数据?

什么是正确的MySQL查询呢?这是我想要达到的。

我想显示所有状态更新条目,发布日期,

海报用户名,性别,城市和标签

我想通过user_id ='1',状态更新发布日期,成员用户名,性别,城市和会员在其个人资料中标记的成员来显示所有状态更新条目

我如何显示用户在他们的个人资料上的所有标签,用','隔开一行?我早些时候尝试过group_concat,但是我无法使它工作。请帮助。

这是我的桌子

STATUS_UPDATE Table

+------------------------------------------------------+

| status_id | user_id | body | postdate |

+-----------+---------+-----------------+--------------+

| 1 | 1 | hello world | Aug 12, 2012 |

+-----------+---------+-----------------+--------------+

| 2 | 1 | i miss you | Aug 13, 2012 |

+-----------+---------+-----------------+--------------+

| 3 | 2 | lorem ipsum | Aug 14, 2012 |

+-----------+---------+-----------------+--------------+

| 4 | 2 | why me? why? | Aug 14, 2012 |

+-----------+---------+-----------------+--------------+

MEMBERS Table //Primary data of members

+---------------------------------------------------+

| user_id | username | password | email |

+---------+----------+------------+-----------------+

| 1 | john_doe | qwerty | john@doe.com |

+---------+----------+------------+-----------------+

| 2 | maryjane | pass123 | mary@jane.com |

+---------+----------+------------+-----------------+

MEMBERS_DATA Table //Profile Fields

+----------------------------------------------+

| user_id | gender | description | city |

+---------+--------+---------------+-----------+

| 1 | male | i am simple | chicago |

+---------+--------+---------------+-----------+

| 2 | female | i am flirty | newyork |

+---------+--------+---------------+-----------+

MEMBERS_TAGS Table //tags that members added to their profiles

+-------------------+

| user_id | item_id |

+---------+---------+

| 1 | 555 |

+---------+---------+

| 1 | 666 |

+---------+---------+

| 1 | 7777 |

+---------+---------+

| 2 | 8888 |

+---------+---------+

TAGS Table //the info of the tags

+------------------------------+

| item_id | cat_id | name |

+---------+--------+-----------+

| 555 | 5 | sexy |

+---------+--------+-----------+

| 666 | 5 | beauty |

+---------+--------+-----------+

| 7777 | 6 | music |

+---------+--------+-----------+

| 8888 | 6 | movies |

+---------+--------+-----------+

CATEGORY Table //the category of the tags

+-------------------------+

| cat_id | category_name |

+---------+---------------+

| 5 | appearance |

+---------+---------------+

| 6 | hobbies |

+---------+---------------+顺便说一句,我在PHP编码,我想事先感谢你的帮助。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值