where-in

How to make multiple WHERE IN column query in Doctrine query builder?

白昼怎懂夜的黑 提交于 2019-12-05 00:44:23
问题 I would like to update multiple records in db using WHERE IN statement with two column check. Pure MySql raw query looks something like this.. and it works: UPDATE poll_quota q SET q.count = q.count+1 WHERE q.form_id=14 AND ((q.field_id,q.value) IN (('A',1),('B',1))) My code: $this->createQueryBuilder("q") ->update() ->set("q.count","q.count+1") ->where("q.form_id=:form_id") ->andWhere("((q.field_id,q.value) IN (:wherein))") ->setParameter(":form_id",$form_id) ->setParameter(":wherein",$where

Pass string into SQL WHERE IN

独自空忆成欢 提交于 2019-12-04 08:10:55
I am working on a query page where a user selects a value which represents different types, each identified by an ID. The problem is selecting these IDs from the data base using the WHERE IN method. This is my SQL statement SELECT M.REG_NO, T.TYPE_ID FROM MAIN AS M INNER JOIN CLASSIFICATION AS C ON M.REG_NO = C.REG_NO INNER JOIN TYPE AS T ON T.TYPE_ID = C.TYPE_ID WHERE T.TYPE_ID IN (@Types) it will work for one single value, eg. 46, but NOT if the value is in brackets, eg. (46) or ('46'), the way it should be for the IN. I am using visual studio which is auto generating the method to access

Where IN a Comma delimited string [duplicate]

大兔子大兔子 提交于 2019-12-04 06:01:41
This question already has answers here : Closed 4 years ago . Passing a varchar full of comma delimited values to a SQL Server IN function (22 answers) I would like retrieve a certain users from a full list of a temp table #temptable. The query is like this: DECLARE @List varchar(max) SELECT @List = coalesce(@List + ',','') + '''' + StaffCode + '''' FROM tblStaffs SELECT UserName FROM #temptable WHERE #temptable.StaffCode IN (@List) I can tell @List is in a right format: 'AAA','ABB','BBB','CCC','DDD','MMM' And if I change it to WHERE #temptable.StaffCode IN ('AAA','ABB','BBB','CCC','DDD','MMM'

“Query is too complex” exception in MS Access 2010

走远了吗. 提交于 2019-12-04 04:05:59
问题 The following query is generating an exception. How can I simplify it? UPDATE Word SET CorrectnessCount=@CorrectnessCount WHERE GroupNo=@GroupNo AND (Name=@Adduce OR Name=@Assuage OR Name=@Athwart OR Name=@Auscultation OR Name=@Bedizen OR Name=@Behoove OR Name=@Benignant OR Name=@Betrothal OR Name=@Brazier OR Name=@Bungle OR Name=@Callow OR Name=@Caparison OR Name=@Carillon OR Name=@Caryatid OR Name=@Catechism OR Name=@Caustic OR Name=@Cavalier OR Name=@Chagrin OR Name=@Chasm OR Name=@Clamber

difference between where_in and find_in_set

半腔热情 提交于 2019-12-02 14:18:20
问题 I am working on a join query in which I have to get the data from a column which contain the comma separated values.like allowed_activity contain 1,2,3,4,5,6 this the activity_id which is allowed. So In the query, I am checking that current activity is allowed or not and for that, I have used where_in and also tried find_in_set in where condition. Here is that part of the query: $this->db->where_in('a.allowed_activity',$activity_id); //And With FIND_IN_SET $this->db->where("FIND_IN_SET(

Dapper WHERE IN statement with ODBC

心已入冬 提交于 2019-12-02 07:11:32
问题 I am using Dapper on ODBC provider, which as known does not support named parameters. For most of my queries I used pseudo named parameters: ?name? . However, when I try to string query = $"select * from \"{TableName}\" where ID in ?Ids?"; return connection.Query<CdfGroupByCdfUserRecord>(query, new {Ids = ids}).ToArray(); I see that Dapper generates query select * from "MY_TABLE" where ID in (?Ids1,?Ids2,?Ids3,?Ids4,?Ids5)? What should I do to get it work? 回答1: This appears to be a bug in

Dapper WHERE IN statement with ODBC

流过昼夜 提交于 2019-12-02 06:59:48
I am using Dapper on ODBC provider, which as known does not support named parameters. For most of my queries I used pseudo named parameters: ?name? . However, when I try to string query = $"select * from \"{TableName}\" where ID in ?Ids?"; return connection.Query<CdfGroupByCdfUserRecord>(query, new {Ids = ids}).ToArray(); I see that Dapper generates query select * from "MY_TABLE" where ID in (?Ids1,?Ids2,?Ids3,?Ids4,?Ids5)? What should I do to get it work? This appears to be a bug in dapper. I'll try to fix it for 1.50.2. I've logged it (for tracking purposes) here 来源: https://stackoverflow

difference between where_in and find_in_set

爱⌒轻易说出口 提交于 2019-12-02 05:21:00
I am working on a join query in which I have to get the data from a column which contain the comma separated values.like allowed_activity contain 1,2,3,4,5,6 this the activity_id which is allowed. So In the query, I am checking that current activity is allowed or not and for that, I have used where_in and also tried find_in_set in where condition. Here is that part of the query: $this->db->where_in('a.allowed_activity',$activity_id); //And With FIND_IN_SET $this->db->where("FIND_IN_SET($activity_id, a.allowed_activity) !=",0); Problem or Confusion When I use where_in it doesn't give me the

WHERE field1 IN (NULL)

萝らか妹 提交于 2019-12-02 04:05:46
I want to retrieve data from the table based on a couple of columns, some with data, other with NULL. In the first code example below, the procedure is fine - all the rows are returned. In the second example no rows are returned - because NULL=NULL return FALSE. The third example is more or less what I have in mind, when the column has NULL values, then this clause has to be "ignored" and only the data in the first two columns are used to return the rows based on these two columns. SELECT * FROM XYZ WHERE col1 IN ('a', 'b') AND col2 IN ('c', 'd') AND col3 IN ('e', 'f') SELECT * FROM XYZ WHERE

“Query is too complex” exception in MS Access 2010

早过忘川 提交于 2019-12-01 21:33:26
The following query is generating an exception. How can I simplify it? UPDATE Word SET CorrectnessCount=@CorrectnessCount WHERE GroupNo=@GroupNo AND (Name=@Adduce OR Name=@Assuage OR Name=@Athwart OR Name=@Auscultation OR Name=@Bedizen OR Name=@Behoove OR Name=@Benignant OR Name=@Betrothal OR Name=@Brazier OR Name=@Bungle OR Name=@Callow OR Name=@Caparison OR Name=@Carillon OR Name=@Caryatid OR Name=@Catechism OR Name=@Caustic OR Name=@Cavalier OR Name=@Chagrin OR Name=@Chasm OR Name=@Clamber OR Name=@Clarion OR Name=@Clavicle OR Name=@Coadjutor OR Name=@Coax OR Name=@Cockade OR Name=@Coddle