lundi 23 mars 2015

Generate value not in mysql table

I have used following query that use to generate random value not in mysql table.



SELECT FLOOR( RAND()*1000 + 50 ) AS temp FROM tempcode WHERE 'temp' NOT IN ( SELECT code FROM tempcode ) LIMIT 1


but when I reduce the value to RAND()*4 for checking purpose using dummy data that not functioning well.



SELECT FLOOR( RAND()*1000 + 50 ) AS temp FROM tempcode WHERE 'temp' NOT IN ( SELECT code FROM tempcode ) LIMIT 1


What would be the reason? Any suggestions to generate value not in mysql table?





Aucun commentaire:

Enregistrer un commentaire