I admit that I'm a novice in creating a query but I appreciate if somebody can share their knowledge to achieve my intension.
Here is my scenario, I want to insert a random record from Table1 which is not exist in Table2.
I found a query that insert a record from Table1 and does not exist in Table 2, but the problem with this query if I run it again it will give me the same result from the first time I run it. Below is the statement:
INSERT INTO tbl_table1 ( Field1, Field2, Field3 )
SELECT TOP 1 tbl_table2.[Field1], tbl_table2.[Field2], tbl_table2.[field3]
FROM tbl_table2
WHERE NOT EXISTS (SELECT tbl_table1.[Field1], tbl_table1.[Field2], tbl_table1.[Field3]
FROM tbl_table1
WHERE tbl_table1.[Field1] = tbl_table2.[Field1]);
I don't know where to insert the statement below so it will pick up a random record from tbl_table2, this statement will pick up a random record.
ORDER BY Rnd((INT(NOW*[tbl_table2.ID])-NOW*[tbl_table2.ID]))
Thanks you in advance and I appreciate for the help.
Here is my scenario, I want to insert a random record from Table1 which is not exist in Table2.
I found a query that insert a record from Table1 and does not exist in Table 2, but the problem with this query if I run it again it will give me the same result from the first time I run it. Below is the statement:
INSERT INTO tbl_table1 ( Field1, Field2, Field3 )
SELECT TOP 1 tbl_table2.[Field1], tbl_table2.[Field2], tbl_table2.[field3]
FROM tbl_table2
WHERE NOT EXISTS (SELECT tbl_table1.[Field1], tbl_table1.[Field2], tbl_table1.[Field3]
FROM tbl_table1
WHERE tbl_table1.[Field1] = tbl_table2.[Field1]);
I don't know where to insert the statement below so it will pick up a random record from tbl_table2, this statement will pick up a random record.
ORDER BY Rnd((INT(NOW*[tbl_table2.ID])-NOW*[tbl_table2.ID]))
Thanks you in advance and I appreciate for the help.