mercredi 14 août 2019

How to union select with random and limit

I'm trying to random my training data or machine learning. In my table have column that save just two value "A" and "B". But when I using random query, both of that value that show isn't equal and my code isn't working. How to fix this? I'm really bad on MySQL T.T

I'm using MySQL on XAMPP

SELECT * FROM ( (SELECT * FROM table WHERE table.category = 'A' LIMIT 10) as t1 UNION ALL (SELECT * FROM table WHERE table.category = 'A' LIMIT 10) as t2 ) ORDER BY RAND()

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'as t2 ) ORDER BY RAND() LIMIT 0, 25' at line 5




Aucun commentaire:

Enregistrer un commentaire