sql-in

passing an Array as a Parameter to be used in a SQL Query using the “IN” Command

别说谁变了你拦得住时间么 提交于 2019-12-23 13:08:52
问题 Good Afternoon to All, I have a question concerning on SQL Queries. is it possible to use an array as a parameter to a query using the "IN" command? for example, int x = {2,3,4,5} UPDATE 'table_name' set 'field' = data WHERE field_ID IN (x) the reason I am asking this is to avoid an iterative SQL Statement when I have to update data in a database. I also thought of using a for each statement in for the UPDATE Query but I don't know if it will affect the performance of the query if it will

SQL IN Statement - Value In (database_field)

主宰稳场 提交于 2019-12-20 02:58:42
问题 Part of a search query i'm building requires filter values to be processed through an SQL query to check against a CSV list within a database field. (I have no control over the use/non use of CSV lists within database fields, working with what i have) and I have done a little testing and found that you can do the following: Where database_field In (#CSV_list#) If database_field equalled 2 and CSV_list equalled 1,2,3,4 this would return true as the value of 2 was found within the CSV list.

postgreSQL - in vs any

て烟熏妆下的殇ゞ 提交于 2019-12-17 22:45:37
问题 I have tried both 1) smthng = any (select id from exmplTable) 2) smthng in (select id from exmplTable) and I am getting the same results for my data. Is there any difference for the two expresions ? 回答1: No, in these variants are same: You can see - the execution plans are same too: postgres=# explain select * from foo1 where id in (select id from foo2); ┌──────────────────────────────────────────────────────────────────┐ │ QUERY PLAN │ ╞═══════════════════════════════════════════════════════

mysql force order of results found to match order of IN clause

被刻印的时光 ゝ 提交于 2019-12-13 07:41:53
问题 This question is different to a commonly asked question about ordering the final results by the IN clause. I would like to force the results returned by the query that contains the IN clause, to match the order of the IN clause. This is the original question that I am working from. I'd like to alter the query below so that a row containing progress=2 occurs before progress=4 and progress=7 for each session_id when ordering the formation_page_hits table by datetime . Here is the current query:

Difficulty using an array as part of PDO “IN” query

情到浓时终转凉″ 提交于 2019-12-12 02:26:40
问题 I'm trying to query a MySQL databse using an array. $array=array('Group1','Group2','Group3'); $inQuery=implode(",",$array); //$inQuery='Group1'; //This returns the expected result, but is obviously not an array $data=array($inQuery); try { $STH = $this->DBH->prepare('SELECT GroupName FROM myTable WHERE GroupName IN(?)'); $STH->execute($data); /* Output results*/ } catch(PDOException $e) { /*Panic!*/ } I am not getting any error messages, just 0 results. Any help would be appreciated! 回答1: You

WHERE Column IN from parameter in DB2 over SSIS

流过昼夜 提交于 2019-12-11 00:58:37
问题 I want to do the following command in a SSIS Package to DB2. UPDATE MyTable SET Col1 = ?, Col2 = ? WHERE Col3 IN (?) The Parameters are connected and the package is finished successfully but no row is updated. The Col3 contains values like 123 , 452 and so on and the third parameter is a string with a content like 345,432,456,432,667,123,456 . What have I to change to be able to update the rows? I tried it with the following. In SQL Server it would work but in DB2 not. UPDATE MyTable SET Col1

Slick: How can I combine a SQL LIKE statement with a SQL IN statement

有些话、适合烂在心里 提交于 2019-12-08 05:09:36
问题 I basically would like to replace the following code with something more "slicky": final case class User(firstName: String, lastName: String) def dbAction(lastNameParts: Seq[String]): SqlStreamingAction[Vector[User], User, Effect] implicit val getUserResult = GetResult((r: PositionedResult) => { val resultSet: ResultSet = r.rs User( resultSet.getString(1), resultSet.getString(2) ) }) val pattern = orgIds.mkString("|") sql"""SELECT u.first_name, u.last_name FROM users u WHERE last_name ~*

Slick: How can I combine a SQL LIKE statement with a SQL IN statement

。_饼干妹妹 提交于 2019-12-08 04:19:28
I basically would like to replace the following code with something more "slicky": final case class User(firstName: String, lastName: String) def dbAction(lastNameParts: Seq[String]): SqlStreamingAction[Vector[User], User, Effect] implicit val getUserResult = GetResult((r: PositionedResult) => { val resultSet: ResultSet = r.rs User( resultSet.getString(1), resultSet.getString(2) ) }) val pattern = orgIds.mkString("|") sql"""SELECT u.first_name, u.last_name FROM users u WHERE last_name ~* $pattern""".as[User] So the resulting SQL would be: SELECT u.first_name, u.last_name FROM users u WHERE

Node.js sqlite3 IN operator

女生的网名这么多〃 提交于 2019-12-04 20:49:34
问题 So I am currently trying to make a query in Node.js: // friends is an array object db.all('SELECT email ' + 'FROM users' + 'WHERE email in ?', friends, function(err, rows) { if (!err) { I know that you can pass in an array of parameters for every '?' symbol, but is it possible to use the IN operator in this case? If not, should I do string concatenation or prepared statements? 回答1: F.e. db.all('SELECT email ' + 'FROM users' + 'WHERE email in ( ' + friends.map(function(){ return '?' }).join(',

Using IN clause in a native sql query

☆樱花仙子☆ 提交于 2019-11-29 03:42:55
We are trying to dynamically generate an IN clause for a native sql query to return a JPA entity. Hibernate is our JPA provider. Our code looks something like this. @NamedQuery( name="fooQuery", queryString="select f from Foo f where f.status in (?1)" ) .... Query q = entityManager.createNamedQuery("fooQuery"); q.setParameter(1, "('NEW','OLD')"); return q.getResultList(); This doesn't work, the in clause does not recognize any of the values passed in via this manner. Does anyone know of a solution to this problem? topchef JPA supports named list parameters, in your case: @NamedQuery( name=