(SELECT * FROM table1
INNER JOIN table2
ON table1.id = table2.id)
AS t1
JOIN (SELECT ROUND(RAND() * (SELECT MAX(table1.id) FROM table1)) AS id)
AS t2
WHERE t1.id >= t2.id
LIMIT 1)
I try to use RAND() max(id) to get a random mysql result, but get a #1064 error.
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS t1 JOIN (SELECT ROUND(RAND() * (SELECT MAX(table1.id) FROM table1))' at line 1
Where is the problem? thanks.
(assuming that this code snippet is an entire query)
May be wrong but your statement does not have a SELECT … in short it looks like this:
t1 JOIN t2 WHERE …
There is no SELECT something FROM t1 JOIN t2 WHERE …
Not sure if I make myself clear…
Addendum:
Not sure what you re trying to achieve, but this code bellow returns random IDs from your tables (variation of your query) so perhaps you can use it. A bit messy perhaps but then again I have no idea what are you trying to achieve :).
You can select id1 or id2 instead of *, depending on what is your goal…