sql-like

Like Case Sensitive in MySQL

亡梦爱人 提交于 2019-11-26 09:41:05
问题 I have a MySQL query: SELECT concat_ws(title,description) as concatenated HAVING concatenated LIKE \'%SearchTerm%\'; And my table is encoded utf8_general_ci with MyISAM. Searches seem to be case sensitive. I can\'t figure out how to fix it. What\'s going wrong and/or how do I fix it? 回答1: Try this: SELECT LOWER(CONCAT_WS(title,description)) AS concatenated WHERE concatenated LIKE '%searchterm%' or (to let you see the difference) SELECT LOWER(CONCAT_WS(title,description)) AS concatenated WHERE

mysql like performance boost

微笑、不失礼 提交于 2019-11-26 09:10:06
问题 is there anyway to speed up mysql like operator performance if wild card is involved? eg. like \'%test%\' 回答1: MySQL can use an index if your query looks like foo LIKE 'abc%' or foo LIKE 'abc%def%' . It can use the index for any portion or the string before the first wildcard. If you need to match a word anywhere within a string, you might want to consider using FULLTEXT indexes instead. More detail on indexes: http://dev.mysql.com/doc/refman/5.1/en/mysql-indexes.html Full text search: http:/

Python SQLite parameter substitution with wildcards in LIKE

你离开我真会死。 提交于 2019-11-26 08:56:40
问题 I am attempting to use a parametrized LIKE query with Python\'s Sqlite library as below: self.cursor.execute(\"select string from stringtable where string like \'%?%\' and type = ?\", (searchstr,type)) but the ? inside of the wildcard is not being evaluated leaving me with this error: \"sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 2 supplied.\" I also tried to use the tagged version of querying with: like \'%:searchstr%\' and in

How can I use 'Not Like' operator in MongoDB

扶醉桌前 提交于 2019-11-26 08:11:43
问题 I can use the SQL Like Operator using pymongo , db.test.find({\'c\':{\'$regex\':\'ttt\'}}) But how can I use Not Like Operator? I tried db.test.find({\'c\':{\'$not\':{\'$regex\':\'ttt\'}}) but got error: OperationFailure: $not cannot have a regex 回答1: From the docs: The $not operator does not support operations with the $regex operator. Instead use // or in your driver interfaces, use your language’s regular expression capability to create regular expression objects. Consider the following

LIKE vs CONTAINS on SQL Server

本秂侑毒 提交于 2019-11-26 07:54:55
问题 Which one of the following queries is faster (LIKE vs CONTAINS)? SELECT * FROM table WHERE Column LIKE \'%test%\'; or SELECT * FROM table WHERE Contains(Column, \"test\"); 回答1: The second (assuming you means CONTAINS, and actually put it in a valid query) should be faster, because it can use some form of index (in this case, a full text index). Of course, this form of query is only available if the column is in a full text index. If it isn't, then only the first form is available. The first

LIKE operator in LINQ

江枫思渺然 提交于 2019-11-26 07:37:46
问题 Is there any way to compare strings in a C# LINQ expression similar to SQL\'s LIKE operator? Suppose I have a string list. On this list I want to search a string. In SQL, I could write: SELECT * FROM DischargePort WHERE PortName LIKE \'%BALTIMORE%\' Instead of the above, query want a linq syntax. using System.Text.RegularExpressions; … var regex = new Regex(sDischargePort, RegexOptions.IgnoreCase); var sPortCode = Database.DischargePorts .Where(p => regex.IsMatch(p.PortName)) .Single()

Parameter in like clause JPQL

 ̄綄美尐妖づ 提交于 2019-11-26 06:32:30
问题 I am trying to write a JPQL query with a like clause: LIKE \'%:code%\' I would like to have code=4 and find 455 554 646 ... I cannot pass :code = \'%value%\' namedQuery.setParameter(\"%\" + this.value + \"%\"); because in another place I need :value not wrapped by the % chars. Any help? 回答1: If you do LIKE :code and then do namedQuery.setParameter("code", "%" + this.value + "%"); Then value remains free from the '%' sign. If you need to use it somewhere else in the same query simply use

MySQL Like multiple values

人走茶凉 提交于 2019-11-26 06:13:54
问题 I have this MySQL query. I have database fields with this contents sports,shopping,pool,pc,games shopping,pool,pc,games sports,pub,swimming, pool, pc, games Why does this like query does not work? I need the fields with either sports or pub or both? SELECT * FROM table WHERE interests LIKE (\'%sports%\', \'%pub%\') 回答1: The (a,b,c) list only works with in . For like , you have to use or : WHERE interests LIKE '%sports%' OR interests LIKE '%pub%' 回答2: Faster way of doing this: WHERE interests

How to speed up SELECT .. LIKE queries in MySQL on multiple columns?

六月ゝ 毕业季﹏ 提交于 2019-11-26 05:58:06
问题 I have a MySQL table for which I do very frequent SELECT x, y, z FROM table WHERE x LIKE \'%text%\' OR y LIKE \'%text%\' OR z LIKE \'%text%\' queries. Would any kind of index help speed things up? There are a few million records in the table. If there is anything that would speed up the search, would it seriously impact disk usage by the database files and the speed of INSERT and DELETE statements? (no UPDATE is ever performed) Update : Quickly after posting, I have seen a lot of information

Search for string within text column in MySQL

落爺英雄遲暮 提交于 2019-11-26 05:30:01
问题 I have mysql table that has a column that stores xml as a string. I need to find all tuples where the xml column contains a given string of 6 characters. Nothing else matters--all I need to know is if this 6 character string is there or not. So it probably doesn\'t matter that the text is formatted as xml. Question: how can I search within mysql? ie SELECT * FROM items WHERE items.xml [contains the text \'123456\'] Is there a way I can use the LIKE operator to do this? 回答1: You could probably