Consultation with combined criteria

1

I'm trying to assign more than one search criteria to the database, and I can not find anything that can help me. I'll explain better:

I have a database with a "city" field, where I want the data assigned to that city to be returned. However, I would like another nearby city to be included too, but I would not want to do this with an auxiliary table.

I've seen this being used with commas in forms, but I have no idea how to do this in the query.

$acha = mysqli_query("
SELECT *
FROM pe_basedecisao 
WHERE cidade = 351015, 351013");
    
asked by anonymous 23.11.2017 / 15:09

1 answer

4

You can do this with IN in mysql:

Query using 'IN'

SELECT * FROM pe_basedecisao WHERE cidade IN ("351015", "351013");

Translation of this query without 'IN'

SELECT * FROM pe_basedecisao WHERE cidade = "351015" OR cidade = "351013";

Reference: MySQL IN

    
23.11.2017 / 15:17