SQL query, select from 2 tables random
Posted
by
klaus
on Stack Overflow
See other posts from Stack Overflow
or by klaus
Published on 2011-01-07T15:36:27Z
Indexed on
2011/01/07
15:53 UTC
Read the original article
Hit count: 200
Hello all i have a problem that i just CANT get to work like i what it..
i want to show news and reviews (2 tables) and i want to have random output and not the same output
here is my query i really hope some one can explain me what i do wrong
SELECT
anmeldelser.billed_sti ,
anmeldelser.overskrift ,
anmeldelser.indhold ,
anmeldelser.id ,
anmeldelser.godkendt
FROM
anmeldelser
LIMIT 0,6
UNION ALL
SELECT
nyheder.id ,
nyheder.billed_sti ,
nyheder.overskrift ,
nyheder.indhold ,
nyheder.godkendt
FROM nyheder
ORDER BY rand() LIMIT 0,6
© Stack Overflow or respective owner