Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 178
  • Last Modified:

MySQL: Randomly Return 1 or -1

This randomly returns 1 or 0.

SELECT FLOOR(RAND()*2) 

Open in new window

I want it to randomly select 1 or -1
0
hankknight
Asked:
hankknight
1 Solution
 
Robert SchuttSoftware EngineerCommented:
Try:
SELECT FLOOR(RAND()*2)*2-1

Open in new window

0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now