I want to do an SQL join query. I have three tables _A, _B, _C, say. ANd each table has a column named “level” with some items having value 1,2,3 in this column.
At first, I just wanted an item with level = 1 from table _A, and so wrote:
SELECT * FROM _A WHERE level = "1" ORDER BY RANDOM() LIMIT 1
which worked fine.
Now, I want to select a random item with level=1 from any one of the three tables.
I wrote:
SELECT * FROM _A, _B, _C WHERE level = "1" ORDER BY RANDOM() LIMIT 1
It didn’t work. The system crashed. But my reference book says this is the way to do it. Please help.
1 Answer