MySQL Rand()函数

MySQL Rand()函数

MySQL Rand() 函数可以被调用,以产生一个在 0 和 1 之间的随机数:

mysql>  SELECT RAND( ), RAND( ), RAND( );
+------------------+-----------------+------------------+
| RAND( )          | RAND( )         | RAND( )          |
+------------------+-----------------+------------------+
| 0.45464584925645 | 0.1824410643265 | 0.54826780459682 |
+------------------+-----------------+------------------+
1 row in set (0.00 sec)

当使用整数作为参数调用时,RAND()使用该值作为随机数的种子发生器。每次种子使用给定值生成,RAND()将产生一个可重复的系列数字:

mysql>  SELECT RAND(1), RAND( ), RAND( );
+------------------+------------------+------------------+
| RAND(1 )         | RAND( )          | RAND( )          |
+------------------+------------------+------------------+
| 0.18109050223705 | 0.75023211143001 | 0.20788908117254 |
+------------------+------------------+------------------+
1 row in set (0.00 sec)

可以使用ORDER BY RAND()进行随机行集或值,如下:

要理解ORDER BY RAND()函数,考虑一个employee_tbl表,有以下记录:

mysql> SELECT * FROM employee_tbl;
+------+------+------------+--------------------+
| id   | name | work_date  | daily_typing_pages |
+------+------+------------+--------------------+
|    1 | John | 2007-01-24 |                250 |
|    2 | Ram  | 2007-05-27 |                220 |
|    3 | Jack | 2007-05-06 |                170 |
|    3 | Jack | 2007-04-06 |                100 |
|    4 | Jill | 2007-04-06 |                220 |
|    5 | Zara | 2007-06-06 |                300 |
|    5 | Zara | 2007-02-06 |                350 |
+------+------+------------+--------------------+
7 rows in set (0.00 sec)

现在,使用下面的命令:

mysql> SELECT * FROM employee_tbl ORDER BY RAND();
+------+------+------------+--------------------+
| id   | name | work_date  | daily_typing_pages |
+------+------+------------+--------------------+
|    5 | Zara | 2007-06-06 |                300 |
|    3 | Jack | 2007-04-06 |                100 |
|    3 | Jack | 2007-05-06 |                170 |
|    2 | Ram  | 2007-05-27 |                220 |
|    4 | Jill | 2007-04-06 |                220 |
|    5 | Zara | 2007-02-06 |                350 |
|    1 | John | 2007-01-24 |                250 |
+------+------+------------+--------------------+
7 rows in set (0.01 sec)

mysql> SELECT * FROM employee_tbl ORDER BY RAND();
+------+------+------------+--------------------+
| id   | name | work_date  | daily_typing_pages |
+------+------+------------+--------------------+
|    5 | Zara | 2007-02-06 |                350 |
|    2 | Ram  | 2007-05-27 |                220 |
|    3 | Jack | 2007-04-06 |                100 |
|    1 | John | 2007-01-24 |                250 |
|    4 | Jill | 2007-04-06 |                220 |
|    3 | Jack | 2007-05-06 |                170 |
|    5 | Zara | 2007-06-06 |                300 |
+------+------+------------+--------------------+
7 rows in set (0.00 sec)

94 Responses

  1. Cimmuv说道:

    brand furosemide 40mg lasix 100mg pill buy generic albuterol online

  2. Eozjvi说道:

    strattera online buy order sertraline sertraline 50mg over the counter

  3. Gaukeb说道:

    cost actigall 150mg cetirizine 10mg canada cetirizine 5mg generic

  4. Jporcn说道:

    zithromax pills order omnacortil 20mg online cheap gabapentin 600mg ca

  5. Qmjumt说道:

    best over the counter ppi best treatment for excess gas make your farts smell good

  6. Rstuxq说道:

    prednisone 10mg price oral amoxil amoxicillin 1000mg cost

  7. Ofsdlz说道:

    viagra pills where to buy online prescription birth control who should not take cialis

  8. Zrfbqx说道:

    promethazine sale buy promethazine 25mg for sale buy ivermectin 6mg

  9. Nzijtd说道:

    immediate relief for ulcer pain hypertension medication brand names online doctor visit for uti

  10. Kzuzvs说道:

    cymbalta without prescription purchase modafinil without prescription modafinil 100mg pills

  11. Nfaevp说道:

    strongest antifungal herbs can dehydration cause low blood pressure which bp tablet names

  12. Yanrlw说道:

    purchase cyproheptadine order nizoral 200 mg pills buy nizoral 200 mg pill

  13. Hwysfd说道:

    best antiviral drug for herpes best diabetes medicine type 2 how is type 2 diabetes diagnosed

  14. Gculbu说道:

    medroxyprogesterone sale order praziquantel pills microzide 25 mg usa

  15. Fzbrmr说道:

    nicotine replacement calculator painkillers for arthritis by prescription doctors who prescribe narcotics easily

  16. Rxpbki说道:

    order letrozole 2.5 mg online cheap brand femara 2.5mg abilify 20mg pill

  17. Qoviif说道:

    sleeping pills prescribed online where can i buy doxylamine good weight loss supplements gnc

  18. Suymeq说道:

    generic uroxatral upper abdominal pain prescription medication daily heartburn relief

  19. Kibiko说道:

    how to buy minocin minomycin online order ropinirole 1mg canada

  20. Wqsdrb说道:

    list of prescription acne medication best acne treatment for adults buy oxcarbazepine 300mg sale

  21. Msgoez说道:

    order catapres online cheap meclizine 25mg tablet tiotropium bromide 9 mcg oral

  22. Pfxmzj说道:

    calcitriol 0.25mg brand order tricor online buy generic fenofibrate

  23. Wvfcsr说道:

    amoxicillin us anastrozole 1 mg price purchase clarithromycin online

  24. Siksyg说道:

    cheap dissertation help play slots online planning poker online

  25. Oyuzib说道:

    cheap term papers buy cefixime medication purchase suprax

  26. Ebbepo说道:

    aspirin 75mg canada real casino slot machine games casino online real money

  27. Fzgjxj说道:

    buy lamisil medication online gambling real money casinos casino games free

  28. Hsompa说道:

    desyrel 50mg pill desyrel generic buy clindac a gel for sale

  29. Chpzam说道:

    order ceftin 250mg without prescription cefuroxime without prescription buy generic methocarbamol

  30. Jeswtq说道:

    tadalafil 10mg oral order diclofenac 100mg pills buy generic indomethacin for sale

  31. Dvrxop说道:

    cheap tamoxifen 10mg betahistine 16 mg without prescription purchase rhinocort generic

  32. Yllsjm说道:

    buy retin gel online cheap buy retin gel online cheap buy cheap stendra

  33. Uzipks说道:

    oral clindamycin best erection pills cheap sildenafil 50mg

  34. Pyhfng说道:

    lamotrigine online order buy prazosin no prescription brand nemazole

  35. Bxrjas说道:

    buy flagyl 200mg generic keflex 500mg cost keflex 500mg for sale

  36. Zfbcxp说道:

    aurogra online generic sildenafil 50mg estrace 2mg drug

  37. Zrulor说道:

    fluconazole without prescription purchase fluconazole pill purchase cipro generic

  38. Vchdzs说道:

    term papers for sale hire essay writer best college paper writing service

  39. Nesvcn说道:

    aldactone 25mg pills spironolactone 100mg canada generic proscar

  40. Ymlckr说道:

    purchase flomax generic ondansetron for sale online simvastatin for sale

  41. Edxpja说道:

    buy cheap motilium sumycin us buy tetracycline 250mg generic

  42. Opezrt说道:

    buy buspin cheap cost amiodarone 200mg buy cordarone 100mg pills

  43. Swwiut说道:

    zantac 150mg drug celebrex 200mg us buy celebrex generic

  44. Kteqyo说道:

    buy allopurinol 300mg generic purchase rosuvastatin buy crestor 10mg online cheap

  45. Frltxb说道:

    imitrex 50mg uk imitrex 50mg without prescription dutasteride us

  46. Qjojwp说道:

    nexium 20mg over the counter remeron 15mg ca order topamax 200mg online cheap

  47. Tlhoyh说道:

    order azelastine 10 ml sale purchase avalide sale brand irbesartan 150mg

  48. Teugkv说道:

    famotidine online prograf 1mg uk order prograf online

  49. Mvcxul说道:

    buy orlistat 120mg xenical 120mg sale diltiazem 180mg uk

  50. Glofte说道:

    brand medex order reglan 10mg reglan us

  51. Ujteqi说道:

    brand glimepiride 1mg buy etoricoxib without prescription buy etoricoxib no prescription

  52. Smwvqv说道:

    nortriptyline 25 mg over the counter purchase panadol without prescription acetaminophen price

  53. Itszet说道:

    oral inderal 20mg motrin 400mg pills buy clopidogrel without prescription

  54. Wfmecw说道:

    where can i buy alendronate purchase macrodantin for sale cost furadantin 100 mg

  55. Xxjctc说道:

    cheap lioresal purchase ozobax for sale toradol pill

  56. Vknodu说道:

    buy claritin no prescription loratadine price how to buy priligy

  57. Zkcmdy说道:

    order lioresal online where can i buy ketorolac buy toradol 10mg online cheap

  58. Ubmsvy说道:

    buy phenytoin 100mg without prescription buy generic dilantin ditropan 5mg cheap

  59. Jkwfkh说道:

    aceon usa allegra 180mg generic fexofenadine for sale

  60. Tgubhl说道:

    buy levitra medication lanoxin pills buy generic tizanidine 2mg

  61. Prnvve说道:

    order medrol for sale adalat brand aristocort 10mg without prescription

  62. Huapbj说道:

    cost serophene brand imuran 50mg imuran 50mg brand

  63. Uytpgw说道:

    win real money online casino cheap levothroid for sale synthroid 100mcg pills

  64. Lpmgqt说道:

    order amantadine 100 mg pills buy cheap generic dapsone generic dapsone 100mg

  65. Vogznj说道:

    blackjack online free gambling game ivermectin side effects

  66. Esktfx说道:

    free slot machine games ventolin 4mg for sale buy cheap ventolin

  67. Myecue说道:

    order protonix sale order pyridium pills phenazopyridine 200 mg without prescription

  68. Aisfdw说道:

    play online blackjack real money buy cheap furosemide buy furosemide 40mg without prescription

  69. Oacsfm说道:

    buy atorvastatin 40mg online cheap order generic lipitor 20mg buy amlodipine 10mg online

  70. Hgxeqo说道:

    azipro 250mg oral buy gabapentin 100mg buy generic neurontin 100mg

  71. Pmoqpi说道:

    accutane oral buy amoxil 250mg generic buy azithromycin 500mg online

  72. Nkvkzz说道:

    purchase omnicef pill purchase glucophage without prescription order lansoprazole 15mg for sale

  73. Uidpcx说道:

    order modafinil 100mg online cheap buy provigil 200mg online cheap prednisone 20mg us

  74. Rpowdn说道:

    buy cenforce cheap cenforce 50mg cost order chloroquine pill

  75. Xkxgxt说道:

    cialis buy online buy cialis 5mg generic viagra 50mg brand

  76. Dmgnfv说道:

    purchase micardis without prescription buy micardis without a prescription order molnupiravir online

  77. Ezmpgm说道:

    buy omeprazole medication montelukast 5mg oral lopressor tablet

  78. Ohflve说道:

    oral premarin sildenafil without prescription viagra 50mg cost

  79. Lyejto说道:

    buy latanoprost without a prescription rivastigmine online rivastigmine generic

  80. Davidval说道:

    Altogether! Declaration news portals in the UK can be awesome, but there are tons resources available to cure you mark the unexcelled identical for the sake of you. As I mentioned in advance, conducting an online search for https://www.home-truths.co.uk/pag/what-is-the-height-of-lawrence-jones-the-fox-news.html “UK newsflash websites” or “British intelligence portals” is a vast starting point. Not one purposefulness this give you a comprehensive list of news websites, but it determination also afford you with a punter brainpower of the in the air news landscape in the UK.
    Once you secure a list of potential news portals, it’s prominent to evaluate each anyone to shape which richest suits your preferences. As an example, BBC Intelligence is known benefit of its ambition reporting of information stories, while The Guardian is known representing its in-depth breakdown of political and social issues. The Unconnected is known for its investigative journalism, while The Times is known in search its business and wealth coverage. Not later than arrangement these differences, you can select the talk portal that caters to your interests and provides you with the rumour you have a yen for to read.
    Additionally, it’s usefulness considering close by news portals with a view explicit regions within the UK. These portals lay down coverage of events and scoop stories that are relevant to the область, which can be exceptionally utilitarian if you’re looking to keep up with events in your town community. In behalf of occurrence, local news portals in London include the Evening Pier and the Londonist, while Manchester Evening Hearsay and Liverpool Repercussion are hot in the North West.
    Inclusive, there are many news portals accessible in the UK, and it’s high-ranking to do your digging to find the united that suits your needs. At near evaluating the unconventional news broadcast portals based on their coverage, style, and essay viewpoint, you can select the a person that provides you with the most relevant and interesting info stories. Decorous success rate with your search, and I hope this data helps you discover the correct news broadcast portal since you!

  81. Zsvgsv说道:

    vasotec where to buy doxazosin generic duphalac cheap

  82. Wcirvz说道:

    purchase mestinon for sale feldene online order buy maxalt pills

  83. Jhxbld说道:

    order ferrous sulfate 100 mg sale oral ascorbic acid 500mg betapace medication

  84. Equdxf说道:

    prasugrel cost buy chlorpromazine pills order tolterodine sale

  85. Ztdnja说道:

    cheap etodolac 600 mg buy monograph 600 mg online cheap cilostazol order online

  86. Michaeladoto说道:

    To announce true to life rumour, ape these tips:

    Look for credible sources: http://levegroup.com/include/pages/?what-is-gnd-news-all-you-need-to-know.html. It’s high-ranking to safeguard that the newscast outset you are reading is reliable and unbiased. Some examples of reputable sources include BBC, Reuters, and The Different York Times. Review multiple sources to get a well-rounded understanding of a precisely news event. This can support you carp a more ended display and escape bias. Be hep of the viewpoint the article is coming from, as flush with respected hearsay sources can be dressed bias. Fact-check the gen with another origin if a scandal article seems too lurid or unbelievable. Always be inevitable you are reading a current article, as expos‚ can change quickly.

    By following these tips, you can fit a more informed news reader and better apprehend the cosmos everywhere you.

  87. Abrpak说道:

    buy duphaston 10mg generic order januvia purchase jardiance without prescription

  88. Cjbubl说道:

    buy meloset order generic cerazette buy danazol 100mg generic

  89. Adobja说道:

    cheap dipyridamole 25mg dipyridamole buy online buy pravachol 10mg online

  90. Dzvvue说道:

    order aspirin 75 mg online cheap aspirin 75mg cost buy cheap generic imiquimod

  91. Izelng说道:

    buy generic acarbose over the counter purchase glyburide for sale order fulvicin 250mg generic

  92. Gabchp说道:

    brand minoxidil flomax us buy ed pill

  93. Rivtny说道:

    cheap cialis sale sildenafil overnight buy sildenafil 100mg online

  94. Fsbhnv说道:

    fenofibrate price buy fenofibrate pills order tricor 200mg generic

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

CAPTCHAis initialing...