I am trying to select a random row from a column in my database.
I need the query to search/make sure that the random row selected is not equal to any of the values stored in two other columns.
Example:
DATABASE NAME: database_name
TABLE1 contains one column: male_id
TABLE2 contains two columns: number_list1 and number_list2
I need a query that will find a random number in the male_id column THAT IS NOT FOUND IN number_list1 or number_list2. Is there anyway to do this? Here was my best shot at it (causes an error):
SELECT male_id FROM TABLE1 WHERE male_id IS NOT (SELECT number_list1 FROM TABLE2)
AND (SELECT number_list2 FROM TABLE2) ORDER BY RAND()