I have a column whose contents can null, a single integer, or several integers separated by a comma. I want to search for specific rows by using my column to filter out unwanted data. Instead of a search string, I have an array that can have a single element or several, How can I work out on this? Am using Node JS + MySQL. The solution below only works when the column data is a single integer. How can I make it work when the column contains several integers too?
connection.query("SELECT * FROM `vw_tenants` WHERE units is not null AND property_code =? AND (floors_comunn IN (?);", [property_code, floors], (err, data) => {
connection.release();
if(err) {
logger.error(err);
result(null);
} else {
result(data);
}
});
The "floors" variable can be [1] or have several elements ie [0,1,3,5,..n]
The "floors_comunn" table column can contain null, single integer ie 3, or a group of integers separated by a comma ie 2,4,5