Cross-Query mySql

0

I'm not really sure how to express myself more, what I need is how I can do a normal and inverted query. Below I have two fields one source and one destination. I need to make a

       $origem = $_post["origem"];
       $destino = $_post["destino"];

       SELECT * FROM produtos
       where  origem LIKE ?  AND  destino LIKE ?
       $sql3->bind_param("sssiisssss",  $origem,$destino);

More what I need and that she accepts the vice verse

Campos<inputtype="text" name="Origem"> 
<input type="text" name="Destino"> 

Base Origem e Destinos
+----+--------+---------+------+---------+
| id | Origem | Destino | nome |  Valor  |
| 01 |  Rio   | Campos  | R C  | 100,00  |
| 02 |Niteroi |  Rio    | N R  | 200,00  |
| 03 | Macaé  | Campos  | M C  | 300,00  |
| 04 | Centro | Barra   | C B  | 400,00  |
    
asked by anonymous 28.09.2017 / 20:13

1 answer

2

% w / o% below returns what you need:

SELECT * FROM produtos
WHERE  (origem LIKE ?  OR  destino LIKE ?) AND (origem LIKE ?  OR  destino LIKE ?)

Passing the parameters would look like this:

$sql3->bind_param("ssss", $origem, $destino, $destino, $origem);
    
28.09.2017 / 20:23