sql-like

How to Partitioning a table using a LIKE criteria in Mysql

被刻印的时光 ゝ 提交于 2019-12-08 11:28:05
问题 I've a large table to partition by value of a field of varchar(200) type. I have already read this question but because the size of the field I cannot use this solution. My question is: Can I use a Like criteria as LIKE 'b%' or LIKE 'o%' and so on? If not, How can I solve this? Thanks in advance, Antonio 回答1: You'd better specify the range as less than ('c') It is short and readable. 回答2: It seems that partitioning on varchar is allowed only if partitioning is by key (no duplicate values and

mysql like issue on partial match

不想你离开。 提交于 2019-12-08 11:22:39
问题 Im having a mysql query like this SELECT group_name FROM t_groups WHERE group_name LIKE '%PCB%'; The results are group_name ------------ PCB Full size PCB Another query, SELECT group_name FROM t_groups WHERE group_name LIKE '%PCB-123%'; group_name ----------- PCB-123 How can i use a query that will show all the three results ?,I mean i need to get all the results that starts or contains PCB 回答1: use RLIKE as you have changed the context of your question so below is my updated answer SELECT

How do you do SQL Like operator in mongoDB using the official C# driver

匆匆过客 提交于 2019-12-08 11:13:23
问题 How do you do the following SQL query in mongodb using the official c# Driver? Select * from tblUser where FirstName Like '%as%' 回答1: I figured out how to do this. You have to use Query.Matches var query = Query.Matches("FirstName", ".*as.*"); 回答2: I'd suggest you visit this site. It has a wealth of material on the official C# driver from 10gen. http://www.mongodb.org/display/DOCS/CSharp+Driver+Tutorial Most answer will just reproduce what is available on the link above. If you have a

What is best way to search from optional parameter to SQL query in a stored procedure?

断了今生、忘了曾经 提交于 2019-12-08 10:23:45
问题 When it comes to search record with optional parameter in SQL stored procedure, out of these two queries. Both return the same results. Considering performance, which one will you use and why? I have a stored procedure which has multiple search parameters and will be searching in multiple tables, with joins from a huge record set. DECLARE @EventName VARCHAR(100) --SET @EventName = '' --SET @EventName = NULL SET @EventName = 'Coffee in Coffee Bean' -- Query - 1 SELECT * FROM EventDetails WHERE

Mysql query LIKE search and using strings with symbols

喜夏-厌秋 提交于 2019-12-08 09:03:24
问题 My problem is having symbols used in the search query. I want users to be able to use symbols without being a problem, but the LIKE function in mysql seems to not be the solution so I need some help. EXAMPLE: If someone searches for "Blue's car" and "Blues car" is in the database, this query will return with 0 results. OR viseversa, if someone searches for "Blues car" and "Blue's car" is in the database, this query will return with 0 results as well. This is an example of what I'm currently

mysql query with like %..% in the where clause returning different results

 ̄綄美尐妖づ 提交于 2019-12-08 08:31:31
I have the following problem (using mysql 5.0.70). In one table I have a varchar field containing some kind of a number, like: "0303A342", "21534463", "35663CE3" etc. Collation is set to utf8_general_ci . The problem shows up when a user of the system is trying to search for a record containing part of this number. SQL query looks like ... WHERE 'number' LIKE '%0303A%' Now if the 'A' in the LIKE part is entered as a Latin A, the result contains only records with Latin A's in them -- as it should. And when the A is Cyrillic , the results are again only those rows containing the Cyrillic A.

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 ~*

MySQL LIKE limiting

允我心安 提交于 2019-12-08 05:01:14
问题 Basicly I have a row in my table, that has the following format for it's value - 1,2,3,4,10,11,21,34 etc.. I'm retrieving values with LIKE statement, but since I'm using it with %<value>% , when searching for 1 it returns 11, 21, 1 and so on. How can I limit it, to return values based on one? 回答1: Instead of col LIKE '%<value>%' do col LIKE '%,<value>,%' OR col LIKE '<value>,%' OR col LIKE '%,<value>' OR col LIKE '<value>' or better yet col REGEXP '(.+,|^)<val>(,.+|$)' But the best solution

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

Using LIKE in a JOIN query

▼魔方 西西 提交于 2019-12-07 23:19:02
问题 I have two separate data tables. This is Table1 : Customer Name Address 1 City State Zip ACME COMPANY 1 Street Road Maspeth NY 11777 This is Table2 : Customer Active Account New Contact ACME Y John Smith I am running a query using the JOIN where only include rows where the joined fields from both tables are equal . I am joining Customer Name from Table1 and Customer from Table2 . Obviously no match. What I am trying to do is show results where the first 4 characters match in each table so I