I'd like to insert a record using values from different tables
just to illustrate:
INSERT INTO tbl1
VALUES([value1], [value2], NOW())
value1
is a number that comes from a cell in a random row in a different tablevalue2
is another number that comes from a cell in a random row in another table
Here's how I'm trying to do it:
INSERT INTO transactions(itemid, userid, tdate)
VALUES((SELECT TOP 1 ID FROM items ORDER BY RND(ID)), (SELECT TOP 1 ID FROM users ORDER BY RND(ID)), (NOW()))
But this throws an error:
Query input must contain at least one table or query
Any help would be greatly appreciated.
Thanks!