the many worldly proceed formulating comma-separated strings collection/array/list?
during work databases i beheld i query strings strings i have put several restrictions where-clause list/array/collection. should feeling this:
select * fan
where customer.id (34, 26, ..., 2);
you foster shortening doubt have collection strings wish emanate comma-separated list strings only string.
my proceed i have used distant something that:
string outcome = "";
boolean initial = true;
for(string twine : collectionofstrings) {
if(first) {
result+=string;
first=false;
} else {
result+=","+string;
}
}
but unequivocally ugly. can't happens there initial look, generally assembled strings (like each sql query) removing complicated.
what your (more) glorious way?
Comments
Post a Comment