SQL Query so as to match content on 2 fields in database : i have a table #__newtoys_variants having many fields of which id and v_prod_id are there.

Now although id is unique - the v_prod_id is product id 

for instance

    id v_prod_id price
    1     7       200
    2     7       220
    3     1       250
    4     1       270
    5     2       300
    6     10      350
    7     9       220
    8     7       195

Now i intend that 404 error should be displayed in front end - if the id and v_prod_id is not matched in front end

Actually this is my url structure

    example.com/index.php?option=com_newtoys&id=2&vid=7

here id value is extracted from #__newtoys_variants and vid is v_prod_id as extracted from #__newtoys_variants

In case a user changes url to say

    example.com/index.php?option=com_newtoys&id=2&vid=1

then want 404 error to be displayed in front end
Here is Table Database 
[![enter image description here][1]][1]
Can any one help on it to achieve same

Here is a brief function - unsure what exactly should be in sql query so that id & v_prod_id should be matched and in case result is zero then error message can be displayed

    function loadProduct($id ,$vid){
    	$mainframe =JFactory::getApplication();
    	$option = JRequest::getCmd('option');
    	$db =JFactory::getDBO();
    	global $Itemid;	
    	$sql = "";

    	$db->setQuery($sql);
    		
    if ($rows = $db->loadObjectlist()) {
    return $rows[0];
    
    } else {
      if ($db->getErrorNum()) {
        JError::raiseError(500, "Something went horribly wrong, the query returned the error ". $db->getErrorMsg());
    
      } else {
     JError::raiseError(404, "404, Page does not Exists ". $db->getErrorMsg());
      }
    }		
    	}


  [1]: https://i.stack.imgur.com/LAZ7n.png