How to compare a query with 2 variables at the same time in a table of the BD?

1

I have an elaborated application, everything works excellent, I only have one detail: I need that when making a query (The plate of a vehicle) it is compared at the same time with 2 variables of a table in the BD (plate_1 and plate_2) How can I achieve it? since the query is only linked to the variable (plate_1) currently, but it is not the idea. I hope you can help me please

$busqueda=""; 
$busqueda=$_POST['busca']; 
mysql_connect("localhost","root","");
mysql_select_db("pnb"); 
if($busqueda != "") { 
    $busqueda = mysql_query("SELECT * FROM accidentes WHERE placa_pv LIKE '%".$busqueda."%'")
}
    
asked by Anto J 10.04.2016 в 22:58
source

1 answer

1

You just have to add one more condition to your SQL query

SELECT * 
FROM accidentes 
WHERE placa_pv LIKE % <$busqueda> % OR 
      placa_2 LIKE % <$busqueda> %
    
answered by 10.04.2016 / 23:33
source