sql-like

Strange length restriction with the DB2 LIKE operator

若如初见. 提交于 2019-12-12 11:36:02
问题 I found a funny issue with DB2 v9.7 and the SQL LIKE operator. Check this out: -- this works and returns one record select 1 from SYSIBM.DUAL where 'abc' like concat('a', 'bc') -- this doesn't work select 1 from SYSIBM.DUAL where 'abc' like concat(cast('a' as varchar(2001)), cast('bc' as varchar(2000))) -- It causes this error (from JDBC): -- No authorized routine named "LIKE" of type "FUNCTION" having compatible -- arguments was found.. SQLCODE=-440, SQLSTATE=42884, DRIVER=4.7.85 I've played

Powershell - LIKE against an array

折月煮酒 提交于 2019-12-12 11:00:24
问题 For every file being processed, its name is being checked to satisfy the condition. For example, given the following list of filters: $excludeFiles = @" aaa.bbb ccccc.* ddddd???.exe "@ | SplitAndTrim; It should exclude a file from processing if it matches any of the lines. Trying to avoid match/regex , because this script needs to be modifiable by someone who does not know it, and there are several places where it needs to implemented. $excludedFiles and similar are defined as a here-string

How to use like clause query in rails?

旧街凉风 提交于 2019-12-12 10:07:58
问题 I wanted to get a json format of the data when searching for the keyword so I use LIKE clause and query like this "select * from employees where fname like ? or mname like ? or lname like ? or username like ? or id like ?", str, str, str, str, str but I want to code it using rails. I have this code in my controller def showemployees str = params[:str] render json: @employee = Employee.where(Employee.employees[:fname].matches("%#{str}%")) or (Employee.employees[:mname].matches("%#{str}%")) or

SQL Not Like Statement not working

瘦欲@ 提交于 2019-12-12 07:39:05
问题 I have the following code within a stored procedure. WHERE WPP.ACCEPTED = 1 AND WPI.EMAIL LIKE '%@MATH.UCLA.EDU%' AND (WPP.SPEAKER = 0 OR WPP.SPEAKER IS NULL) AND WPP.COMMENT NOT LIKE '%CORE%' AND WPP.PROGRAMCODE = 'cmaws3' The NOT LIKE statement is not working, and yes before anyone says anything there are items with the COMMENT column that does not include CORE and all the other columns are ok. Does anyone know what is wrong with this? 回答1: If WPP.COMMENT contains NULL , the condition will

Sql query with special characters - how to handle?

痴心易碎 提交于 2019-12-12 07:23:18
问题 I've few emp names like john,1 devil's corn something like this Now when i'm searching for these names I'm using select * from emp where empname like ('john,1,devil's,corn') But I'm not getting expected values also I'm getting error because emp name contains special charecters like , and '. Can someone help me out how to solve this? 回答1: This assumes you have 3 discrete names in your example string Exact match. you need to double up quotes. select * from emp where empname IN ('john,1' ,

Binding a LIKE pattern value, two different approaches

别等时光非礼了梦想. 提交于 2019-12-12 05:17:26
问题 Is there any functional difference between these two approaches of binding a pattern for a LIKE clause via prepared statements? Constructing the pattern in the client: $stmt = $db->prepare('SELECT * FROM foo WHERE bar LIKE ?'); $stmt->bindValue(1, '%' . $searchTerm . '%'); Constructing the pattern within SQL: $stmt = $db->prepare("SELECT * FROM foo WHERE bar LIKE CONCAT('%', ?, '%')"); $stmt->bindValue(1, $searchTerm); This example uses PHP's PDO adapter, but this is not specific to PHP, PDO,

Using LIKE operator for array of objects inside jsonb field in PostgreSQL

冷暖自知 提交于 2019-12-12 04:18:04
问题 Is it possible to use LIKE operator for single key/value inside array of objects for jsonb field in PostgreSQL 9.4? For example I have: id | body ------------------------------------------------------------ 1 | {"products": [{"name": "qwe", "description": "asd"}, {"name": "zxc", "description": "vbn"}]} I know, I can get a product with something like this: select * from table where 'body'->'products' @> '[{"name": "qwe"}]'::jsonb The question is: can I get this product if I don't know full

Hibernate QueryBuilder how to mimic 'like' query

瘦欲@ 提交于 2019-12-12 03:57:41
问题 I am learning this API now. I have some code as below, but it does an exact match instead of a 'like'. So when I have a String JMeter , and I use Meter , it does not bring it back in the search result but it should. Any help greatly appreciated SearchManager searchManager = Search.getSearchManager(listingIndex); QueryBuilder qb = searchManager.buildQueryBuilderForClass(ListingIndexEntry.class).get(); Query q = qb.keyword().onField("title").matching(title).createQuery(); Thank you Karthik 回答1:

mongodb like concat mysql query

浪尽此生 提交于 2019-12-12 03:46:47
问题 I have a table in Mysql where I have some D and C classes of IPs and I use this table to test if a request IP is in the database OR belongs to the C class like that: select * from My_Table where '192.168.1.12' LIKE CONCAT(ip, '%'); (where 192.168.1.12 is the request IP I am testing against my table) In my Database, if I have the ip '192.168.1' in C format, I will get a match. I was thinking about using MongoDB and have the same information in documents where each IP (either in C or D class

mvc4 PetaPoco like query throwing exception

穿精又带淫゛_ 提交于 2019-12-12 03:15:23
问题 I am using petapoco. and making search query with like please let me know there is right query or not? var context = new PetaPoco.Database(Connection.connectionstring); SqlQuery = @"SELECT MenuId, MenuTitle, OrderNumber, CreatedDate, IsActive from Menu where MenuTitle LIKE @0, '%@MenuTitle%'"; List<MenuPOCO> objMenuPoco = context.Query<MenuPOCO> ( SqlQuery, new { @MenuTitle = MenuTitle }).ToList(); return objMenuPoco; please let me know the syntax is right? I am getting 0 records in each