sql-like

Cannot use a LIKE query in a JDBC PreparedStatement?

不问归期 提交于 2019-11-27 07:35:36
The query code and query: ps = conn.prepareStatement("select instance_id, ? from eam_measurement where resource_id in (select RESOURCE_ID from eam_res_grp_res_map where resource_group_id = ?) and DSN like '?' order by 2"); ps.setString(1,"SUBSTR(DSN,27,16)"); ps.setInt(2,defaultWasGroup); ps.setString(3,"%Module=jvmRuntimeModule:freeMemory%"); rs = ps.executeQuery(); while (rs.next()) { bla blah blah blah ... Returns an empty ResultSet . Through basic debugging I have found its the third bind that is the problem i.e. DSN like '?' I have tried all kinds of variations, the most sensible of which

SQL Server, combining LIKE and IN?

时间秒杀一切 提交于 2019-11-27 07:04:56
问题 Is there an easy way to combine LIKE and IN in one statement in SQL Server, without using a lot of AND and OR ? e.g. I know in MySQL you can do it this way: SELECT * FROM table1 WHERE column1 REGEXP 'value1|value2|value3' 回答1: Not really. There is no alternation operator in the LIKE pattern syntax. If on 2008 you can use SELECT * FROM table1 WHERE EXISTS(SELECT * FROM (VALUES ('value1'), ('value2'), ('value3')) Vals(val) WHERE column1 LIKE '%' + val + '%') You can also use Regular Expressions

Find rows where text array contains value similar to input

。_饼干妹妹 提交于 2019-11-27 06:58:41
问题 I'm trying to get rows where a column of type text[] contains a value similar to some user input. What I've thought and done so far is to use the 'ANY' and 'LIKE ' operator like this: select * from someTable where '%someInput%' LIKE ANY(someColum); But it doesn't work. The query returns the same values as that this query: select * from someTable where 'someInput' = ANY(someColum); I've got good a result using the unnest() function in a subquery but I need to query this in WHERE clause if

Performance of like '%Query%' vs full text search CONTAINS query

最后都变了- 提交于 2019-11-27 06:53:10
I have a situation where I would like to search a single word . For that scenario, which query would be good from a performance point of view? Select Col1, Col2 from Table Where Col1 Like '%Search%' or Select Col1, Col2 from Table Where Col1 CONTAINS(Col1,'Search') ? Full Text Searching (using the CONTAINS) will be faster/more efficient than using LIKE with wildcarding. Full Text Searching (FTS) includes the ability to define Full Text Indexes, which FTS can use. Dunno why you wouldn't define a FTS index if you intended to use the functionality... LIKE with wildcarding on the left side (IE:

MySQL - Why are COLLATION rules ignored by LIKE operator for German ß character

烈酒焚心 提交于 2019-11-27 06:50:18
问题 I'm running the following select statements on MySQL 5.0.88 with utf8 charset and utf8_unicode_ci collation: SELECT * FROM table WHERE surname = 'abcß'; +----+-------------------+------+ | id | forename | surname | +----+-------------------+------+ | 1 | a | abcß | | 2 | b | abcss | +----+-------------+------------+ SELECT * FROM table WHERE surname LIKE 'abcß'; +----+-------------------+------+ | id | forename | surname | +----+-------------------+------+ | 1 | a | abcß | +----+-------------

SQLite Like % and _

*爱你&永不变心* 提交于 2019-11-27 05:50:50
问题 I can't figure out what the underscore character does in an SQLite like statement. The wildcard character, % , is probably the same as in most other SQL databases. So, what does the damn _ character do? 回答1: The underscore is also the same as in most other SQL databases and matches any single character (i.e. it is the same as . in a regular expression). From the fine manual: An underscore ("_") in the LIKE pattern matches any single character in the string. For example: -- The '_' matches the

Combine PHP prepared statments with LIKE

眉间皱痕 提交于 2019-11-27 05:27:28
Anyone know how to combine PHP prepared statements with LIKE? i.e. "SELECT * FROM table WHERE name LIKE %?%"; Chad Birch The % signs need to go in the variable that you assign to the parameter, instead of in the query. I don't know if you're using mysqli or PDO, but with PDO it would be something like: $st = $db->prepare("SELECT * FROM table WHERE name LIKE ?"); $st->execute(array('%'.$test_string.'%')); EDIT :: For mysqli user the following. $test_string = '%' . $test_string . '%'; $st->bind_param('s', $test_string); $st->execute(); You can use the concatenation operator of your respective

Microsoft office Access `LIKE` VS `RegEx`

人盡茶涼 提交于 2019-11-27 04:52:15
I have been having trouble with the Access key term LIKE and it's use. I want to use the following RegEx (Regular Expression) in query form as a sort of "verfication rule" where the LIKE operator filters my results: "^[0]{1}[0-9]{8,9}$" How can this be accomplished? I don't think Access allows regex matches (except in VBA, but that's not what you're asking). The LIKE operator doesn't even support alternation. Therefore you need to split it up into two expressions. ... WHERE (Blah LIKE "0#########") OR (Blah LIKE "0########") ( # means "a single digit" in Access). I know you were not asking

MySQL - How to search for exact word match using LIKE?

白昼怎懂夜的黑 提交于 2019-11-27 04:45:57
I'm using this query to select data: mysql_query("SELECT * FROM products WHERE product_name LIKE '%".$search."%'"); The only problem is, that it sometimes selects more, than I would like. For example, I would like to select product "BLA", but my query select product "BLABLA" as well. To be clear, if i wanted to select "Product 1", I don't want the query to select "Product 11". Does anybody know how to manage that? Thanks. Do you just want to search on word boundaries? If so a crude version might be: SELECT * FROM products WHERE product_name LIKE "% foo %"; Or you could be a bit cleverer and

SQL query for a carriage return in a string and ultimately removing carriage return

强颜欢笑 提交于 2019-11-27 04:16:04
问题 SQL query for a carriage return in a string and ultimately removing carriage return I have some data in a table and there are some carriage returns in places where I don't want them. I am trying to write a query to get all of the strings that contain carriage returns. I tried this select * from Parameters where Name LIKE '%"\n" %' Also select * from Parameters where Name LIKE '\r' ' Both are valid SQL but are not returning what I am looking for. Do I need to use the Like command or a