luceos I tried your query and it did not work for me.
Said the table doesnt exist
luceos I tried your query and it did not work for me.
Said the table doesnt exist
Digeratimvp if you are using a database table prefix, you will have to adjust the code.
clarkwinkelmann I am trying to do that. My database F00 is weak.
clarkwinkelmann I cant seem to get it to work. Can you help?
Digeratimvp what's your database prefix?
clarkwinkelmann
I believe my db prefix is
fldp_
SELECT DISTINCT p.user_id
FROM fldp_posts AS p
JOIN fldp_discussions AS d ON p.fldp_discussion_id = d.id
WHERE d.id = 611671 AND p.user_id != d.user_id
ORDER BY RAND()
LIMIT 1;
SELECT DISTINCT p.user_id
FROM fldp_posts AS p
JOIN fldp_discussions AS d ON p.fldp_discussion_id = d.id
WHERE d.id = 26 AND p.user_id != d.user_id
ORDER BY RAND()
LIMIT 1;
MySQL said: Documentation
#1054 - Unknown column 'p.fldp_discussion_id' in 'on clause'
Digeratimvp
Just a little mistake with the table, the column was without the prefix:
SELECT DISTINCT p.user_id
FROM fldp_posts AS p
JOIN fldp_discussions AS d ON p.discussion_id = d.id
WHERE d.id = 611671 AND p.user_id != d.user_id
ORDER BY RAND()
LIMIT 1;
That should work.
Follow @luceos 1st post instructions
That did work, however each time I try it the results are the same, and not random.
Digeratimvp it seems mysql only creates a randomized number once unless the seed is updated, see https://www.tek-tips.com/threads/order-by-rand-same-every-time.1224219/. So perhaps this would make it more random:
RAND(CURDATE()+CURTIME());
SELECT DISTINCT p.user_id
FROM fldp_posts AS p
JOIN fldp_discussions AS d ON p.discussion_id = d.id
WHERE d.id = 611671 AND p.user_id != d.user_id
ORDER BY RAND()
LIMIT 1;
Not tested.