I have a SQLite Database and I need to join two tables together and output the combined one in random order.
and the database is like this
I'm new to SQLite and after searching and reading tutor, I use the following command:
SELECT Column1 AS Eng,Column2 AS Chn
FROM list1
UNION
SELECT Column1 AS Eng,Column2 AS Chn
FROM list2
ORDER BY Eng RANDOM()
But the output is
sqlite3.OperationalError: near "RANDOM": syntax error
However if I drop RANDOM() function it turns out to be nothing wrong except no random output
SELECT Column1 AS Eng,Column2 AS Chn
FROM list1
UNION
SELECT Column1 AS Eng,Column2 AS Chn
FROM list2
ORDER BY RANDOM()
And if I drop Eng the output is wrong and the message is:
SELECT Column1 AS Eng,Column2 AS Chn
FROM list1
UNION
SELECT Column1 AS Eng,Column2 AS Chn
FROM list2
ORDER BY Eng
the message is
sqlite3.OperationalError: 1st ORDER BY term does not match any column in the result set
I followed the instructions here Select random row(s) in SQLite and here Selecting a Random Row from an SQLite Table
Thank you!