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

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

      1. 使用 MYSQL 创建一个随机数

        时间:2023-06-25
        <i id='I051l'><tr id='I051l'><dt id='I051l'><q id='I051l'><span id='I051l'><b id='I051l'><form id='I051l'><ins id='I051l'></ins><ul id='I051l'></ul><sub id='I051l'></sub></form><legend id='I051l'></legend><bdo id='I051l'><pre id='I051l'><center id='I051l'></center></pre></bdo></b><th id='I051l'></th></span></q></dt></tr></i><div id='I051l'><tfoot id='I051l'></tfoot><dl id='I051l'><fieldset id='I051l'></fieldset></dl></div>
            <tbody id='I051l'></tbody>
        • <legend id='I051l'><style id='I051l'><dir id='I051l'><q id='I051l'></q></dir></style></legend>

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

        • <tfoot id='I051l'></tfoot>

            <bdo id='I051l'></bdo><ul id='I051l'></ul>

                  本文介绍了使用 MYSQL 创建一个随机数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想知道有没有办法选择 100 到 500 之间随机生成的数字以及选择查询.

                  I would like to know is there a way to select randomly generated number between 100 and 500 along with a select query.

                  例如:SELECT name, address, random_number FROM users

                  我不必将此数字存储在 db 中,仅用于显示目的.

                  I dont have to store this number in db and only to use it to display purpose.

                  我尝试过类似这样的方法,但无法正常工作..

                  I tried it something like this, but it can't get to work..

                  SELECT name, address, FLOOR(RAND() * 500) AS random_number FROM users
                  

                  希望有人帮助我.谢谢

                  推荐答案

                  这应该给你想要的:

                  FLOOR(RAND() * 401) + 100
                  

                  通常,FLOOR(RAND() * ( - + 1)) + 生成之间的数字>> 和 包括在内.

                  Generically, FLOOR(RAND() * (<max> - <min> + 1)) + <min> generates a number between <min> and <max> inclusive.

                  更新

                  这个完整的声明应该有效:

                  This full statement should work:

                  SELECT name, address, FLOOR(RAND() * 401) + 100 AS `random_number` 
                  FROM users
                  

                  这篇关于使用 MYSQL 创建一个随机数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  1. <tfoot id='zvipM'></tfoot>

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

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

                        <bdo id='zvipM'></bdo><ul id='zvipM'></ul>