Erwin Pombett
asked on
postgresql , how can i add to my query a list of values to the where clause ?
hello experts,
i'm looking on how to add a list of values at the end of my query in order to
receive the answer only for a group of values.
i'm looking to add somegthing like the last line,
except that my values are not comming from a subquery.
WHERE
CD.rf_card_id = TB.rf_card_id
AND
CD.account_id = AC.account_id
AND
TB.container_id = TB.container_id
AND account_id in (101, 102, 103, 104, 110) <-
thank you in advance.
i'm looking on how to add a list of values at the end of my query in order to
receive the answer only for a group of values.
i'm looking to add somegthing like the last line,
except that my values are not comming from a subquery.
WHERE
CD.rf_card_id = TB.rf_card_id
AND
CD.account_id = AC.account_id
AND
TB.container_id = TB.container_id
AND account_id in (101, 102, 103, 104, 110) <-
thank you in advance.
ASKER
hello gheist,
could you be more explicit please,
i'm not an expert, neither with postgresql nor with english ;o)
what i would need is to view how to write the list,
i'll correcte the string generation after what is correct.
thank you for further help.
could you be more explicit please,
i'm not an expert, neither with postgresql nor with english ;o)
what i would need is to view how to write the list,
i'll correcte the string generation after what is correct.
thank you for further help.
It is not PostgreSQL problem.
How do you pass statement to PostgreSQL?
Where does it come from?
How do you pass statement to PostgreSQL?
Where does it come from?
ASKER
i pass my query from .NET c# to
postgresql 8.4 through Npgsql,
..................
//sb.Append(" TB.weight*0.5 as GEWICHT, ") ;
sb.Append(" CASE WHEN ") ;
sb.Append(" TB.weight*0.5 >= 0.5 AND ") ;
sb.Append(" TB.weight*0.5 <= 5.0 ") ;
sb.Append(" THEN 5.0 ") ;
sb.Append(" ELSE TB.weight*0.5 ") ;
sb.Append(" END AS GEWICHT, ") ;
sb.Append(" 0 as FNFLAG,");
sb.Append(" CD.rf_card_id as RFCID, ");
sb.Append(" AC.account_id as ACCID ");
sb.Append(" FROM ");
sb.Append(" trash_bag as TB, rf_card as CD, account as AC ");
sb.Append(" WHERE ");
sb.Append(" CD.rf_card_id = TB.rf_card_id ");
sb.Append(" AND ");
sb.Append(" CD.account_id = AC.account_id ");
sb.Append(" AND ");
sb.Append(" TB.container_id = TB.container_id ");
// i want to reduce the query by passing a list of containers.
// TIME
// sb.Append(" AND TB.date > '2008-01-01' ");
//sb.Append(" AND TB.date > '" + aBegin.ToString(PgsSymboli cConstant. DATE_FORMA T_DB)+ "'");
sb.Append(" AND TB.date > '" + aBegin.ToString(PgsSymboli cConstant. DATETIME_F ORMAT_DB)+ "'");
// sb.Append(" AND TB.date < '2008-01-31' ");
//sb.Append(" AND TB.date <= '" + _theEnd.ToString(PgsSymbol icConstant .DATE_FORM AT_DB)+ "'");
sb.Append(" AND TB.date <= '" + _theEnd.ToString(PgsSymbol icConstant .DATETIME_ FORMAT_DB) + "'");
sb.Append(" ORDER BY date ASC; ");
DataTable _dtForExport = dba_.ExecuteQuery(sb.ToStr ing());
//DataTable _dtFiltered= FilterZerosAndMinimal(_dtF orExport);
return _dtForExport;
postgresql 8.4 through Npgsql,
..................
//sb.Append(" TB.weight*0.5 as GEWICHT, ") ;
sb.Append(" CASE WHEN ") ;
sb.Append(" TB.weight*0.5 >= 0.5 AND ") ;
sb.Append(" TB.weight*0.5 <= 5.0 ") ;
sb.Append(" THEN 5.0 ") ;
sb.Append(" ELSE TB.weight*0.5 ") ;
sb.Append(" END AS GEWICHT, ") ;
sb.Append(" 0 as FNFLAG,");
sb.Append(" CD.rf_card_id as RFCID, ");
sb.Append(" AC.account_id as ACCID ");
sb.Append(" FROM ");
sb.Append(" trash_bag as TB, rf_card as CD, account as AC ");
sb.Append(" WHERE ");
sb.Append(" CD.rf_card_id = TB.rf_card_id ");
sb.Append(" AND ");
sb.Append(" CD.account_id = AC.account_id ");
sb.Append(" AND ");
sb.Append(" TB.container_id = TB.container_id ");
// i want to reduce the query by passing a list of containers.
// TIME
// sb.Append(" AND TB.date > '2008-01-01' ");
//sb.Append(" AND TB.date > '" + aBegin.ToString(PgsSymboli
sb.Append(" AND TB.date > '" + aBegin.ToString(PgsSymboli
// sb.Append(" AND TB.date < '2008-01-31' ");
//sb.Append(" AND TB.date <= '" + _theEnd.ToString(PgsSymbol
sb.Append(" AND TB.date <= '" + _theEnd.ToString(PgsSymbol
sb.Append(" ORDER BY date ASC; ");
DataTable _dtForExport = dba_.ExecuteQuery(sb.ToStr
//DataTable _dtFiltered= FilterZerosAndMinimal(_dtF
return _dtForExport;
I have asked moderators to add .net area(s), there is nothing specific to PostgreSQL in your .NET program
ASKER
??????
i'd like to know how to set a list of values to restrict my query,
is a question of query,
it doesnt nothing have to do with .NET
i think i 'm not accurate enough with english language
but there's someting I'M SURE "this is a postresql question"
i'd like to know how to set a list of values to restrict my query,
is a question of query,
it doesnt nothing have to do with .NET
i think i 'm not accurate enough with english language
but there's someting I'M SURE "this is a postresql question"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If this is prepared statement - pass array of strings as parameter in place.