0
I have the following array:
var arr = ['A', 'B', 'C'...];
And in my database I have the column categoria
where values are saved in the following mode: 'A,B,C...'
, how could I make a SELECT
picking up each category of arr
and finding the corresponding values of my bank? As there are so many categories, I would like to avoid the use of a loop in arr
.
I tried something like:
var categorias = ["A", "B", "C", "D", "E"];
var sql = "SELECT id_item, titulo, resumo, tipo FROM series WHERE categoria IN ('"+categorias.join()+"')";
But it doesn’t work like in PHP.
The correct is
('"+categorias.join()+"')
– Valdeir Psr
I fixed the code, I forgot to write the quotes
– Leo Letto
If the values are texts, then each one within the
IN
should come in quotes, in case it would stayIN ('A','B','C','D','E')
. For this you can usemap
or various other functions.– Isac
@Isac could make me an example of what it would be like?
– Leo Letto