<small id='xKzTn'></small><noframes id='xKzTn'>

    <i id='xKzTn'><tr id='xKzTn'><dt id='xKzTn'><q id='xKzTn'><span id='xKzTn'><b id='xKzTn'><form id='xKzTn'><ins id='xKzTn'></ins><ul id='xKzTn'></ul><sub id='xKzTn'></sub></form><legend id='xKzTn'></legend><bdo id='xKzTn'><pre id='xKzTn'><center id='xKzTn'></center></pre></bdo></b><th id='xKzTn'></th></span></q></dt></tr></i><div id='xKzTn'><tfoot id='xKzTn'></tfoot><dl id='xKzTn'><fieldset id='xKzTn'></fieldset></dl></div>

    <tfoot id='xKzTn'></tfoot>
        <bdo id='xKzTn'></bdo><ul id='xKzTn'></ul>
      <legend id='xKzTn'><style id='xKzTn'><dir id='xKzTn'><q id='xKzTn'></q></dir></style></legend>

      MySQL select where 等于多个值

      MySQL select where equal to multiple values(MySQL select where 等于多个值)
      • <legend id='ASzf5'><style id='ASzf5'><dir id='ASzf5'><q id='ASzf5'></q></dir></style></legend>
        • <bdo id='ASzf5'></bdo><ul id='ASzf5'></ul>
            <tbody id='ASzf5'></tbody>

            <tfoot id='ASzf5'></tfoot>
          1. <i id='ASzf5'><tr id='ASzf5'><dt id='ASzf5'><q id='ASzf5'><span id='ASzf5'><b id='ASzf5'><form id='ASzf5'><ins id='ASzf5'></ins><ul id='ASzf5'></ul><sub id='ASzf5'></sub></form><legend id='ASzf5'></legend><bdo id='ASzf5'><pre id='ASzf5'><center id='ASzf5'></center></pre></bdo></b><th id='ASzf5'></th></span></q></dt></tr></i><div id='ASzf5'><tfoot id='ASzf5'></tfoot><dl id='ASzf5'><fieldset id='ASzf5'></fieldset></dl></div>

            <small id='ASzf5'></small><noframes id='ASzf5'>

              • 本文介绍了MySQL select where 等于多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有两个数据库,我存储谁在关注谁,另一个存储用户发布的帖子.

                I have two databases, where I store who is following who and another which stores the posts the user makes.

                我想从以下数据库中选择用户关注的所有人,并回显出该用户关注的用户的用户名,并在帖子数据库中查询该用户的帖子.

                I want to select all of the people a user is following from the following database and echo out the usernames of those who that user is following and query the posts database for posts of that user.

                我的问题是如果一个用户关注多个用户怎么办,我从该用户所关注的人的用户 ID 中回显出来,然后我得到了44443344330

                My problem is what if a user is following multiple users, I echoed out of the user id's of the people this user is following and I get 44443344330

                当我用逗号分隔每个 id 时,我得到:

                When I separate each id with commans, I get:

                44,44,33,44,33,0, 
                

                所以让我们给它一个变量 $user_ids;

                so let's give that a variable of $user_ids;

                $user_ids = "44,44,33,44,33,0, ";
                

                查询:

                $get_posts = mysql_query("SELECT * FROM posts WHERE userid = '$user_ids'");
                

                但它所做的只是显示第一个用户 ID 44 的记录.

                but all it does is show the records of the first user id, 44.

                如何检索所有用户的所有记录?

                How can I retrieve all of the records for all the users?

                推荐答案

                查询应该是:

                SELECT * FROM posts WHERE userid IN (44,44,33,44,33,0)
                

                但是,您可能需要重新考虑您的数据模型并确保它是规范化的,以便您可以直接在数据库中表达这种结构,而无需回显到逗号分隔的字符串中.

                However, you may have to rethink your data model and make sure it is normalized, so that you can express this construction directly in the databse without echoing into a comma-separated string.

                为什么你有两个数据库?你的意思是两个?

                Why do you have two databases? Do you mean two tables?

                这篇关于MySQL select where 等于多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)
                MySQL GROUP BY DateTime +/- 3 seconds(MySQL GROUP BY DateTime +/- 3 秒)

                <small id='JZvCs'></small><noframes id='JZvCs'>

                    <tfoot id='JZvCs'></tfoot>
                      • <bdo id='JZvCs'></bdo><ul id='JZvCs'></ul>
                          <tbody id='JZvCs'></tbody>
                        <legend id='JZvCs'><style id='JZvCs'><dir id='JZvCs'><q id='JZvCs'></q></dir></style></legend>
                        • <i id='JZvCs'><tr id='JZvCs'><dt id='JZvCs'><q id='JZvCs'><span id='JZvCs'><b id='JZvCs'><form id='JZvCs'><ins id='JZvCs'></ins><ul id='JZvCs'></ul><sub id='JZvCs'></sub></form><legend id='JZvCs'></legend><bdo id='JZvCs'><pre id='JZvCs'><center id='JZvCs'></center></pre></bdo></b><th id='JZvCs'></th></span></q></dt></tr></i><div id='JZvCs'><tfoot id='JZvCs'></tfoot><dl id='JZvCs'><fieldset id='JZvCs'></fieldset></dl></div>