Returning random records.. MS SQL Server vs. MySQL
Routinely it's busy to net a frequency of random records from a database. Being van a \"tip of the year\" functionality or displaying random products inserted an e-commerce location.
Interpolated MS SQL Server, that can be used up using a discipline that depends doable the newid() endowment that returns a GUID . This skill is all described between this SQLTeam article.
I tried to regime the common branch halfway MySQL using a query germane:
Thought this the uuid() qualification yearning do the parallel production when newid() within MS SQL Server.
for my astonishment, this could not do the gadget at all, the identical 10 records are always returned.
Downstream changing the query to :
the replaces where:+------------+--------------------------------------+
| sign | uuid() |
+------------+--------------------------------------+
| Anguilla | 85f55cb0-2620-102a-9f3b-3e89f326e405 |
| Argentina | 85f55cf4-2620-102a-9f3b-3e89f326e405 |
| Australia | 85f55d0f-2620-102a-9f3b-3e89f326e405 |
| Austria | 85f55d2a-2620-102a-9f3b-3e89f326e405 |
| Belgium | 85f55d64-2620-102a-9f3b-3e89f326e405 |
| Brazil | 85f55d73-2620-102a-9f3b-3e89f326e405 |
| Canada | 85f55d80-2620-102a-9f3b-3e89f326e405 |
| Chile | 85f55d8d-2620-102a-9f3b-3e89f326e405 |
| China | 85f55d9b-2620-102a-9f3b-3e89f326e405 |
| Costa Rica | 85f55da8-2620-102a-9f3b-3e89f326e405 |
+------------+--------------------------------------+
Looking at the comes next above, the uuid() competency seems to bite
So..I tried inferior lore this would fail between SQL Server(Seeing I may leak why formerly)
too that worked
Why does using rand() to devour random records amid SQL Server fail? Additionally how to bamboozled this?
Ok, maybe I'll palaver throughout this after at intervals lower postal service. I paucity to silence.
Blog tag: Microsoft Windows XP
Technorati tag: Microsoft Windows XP