sql-like

LIKE wildcard with multiple fields and spaces in MYSQL

这一生的挚爱 提交于 2020-01-02 03:37:08
问题 I'm having some trouble searching for any similar match in two fields. For example I have a table with the values: CAR MAKE CAR MODEL Ford Mustang (Shelby) Toyota Corolla Seat Leon etc etc. I want to be able to get the result "Ford, Mustang (Shelby)" by searching for any of the following combinations: Ford Mustang Shelby Ford Mustang or any other combination. Is this possible? I've had a good search but it's hard to find the search terms to describe what I mean. 回答1: Split your terms on

Possible bug in VB.NET 'Like' operator?

大兔子大兔子 提交于 2020-01-01 08:36:06
问题 Why is it that the following evaluates as True ? Dim result = "b" Like "*a*b" Thanks. EDIT: To generalize this a bit, the following returns True : "String1" Like "*AnyText1*AnyText2*AnyText???******????*String1" VBA works correctly, returning False . PowerShell works correctly, returning False : PS C:\Users\XXX> "b" -Like "*a*b" False EDIT2: The link to the bug report: https://connect.microsoft.com/VisualStudio/feedback/details/748415/a-bug-in-net-like-operator 回答1: I decided, for fun, to

MySQL LIKE + php sprintf

大兔子大兔子 提交于 2020-01-01 04:20:10
问题 $test = sprintf("SELECT * FROM `table` WHERE `text` LIKE '%%s%'", mysql_real_escape_string('test')); echo $test; output: SELECT * FROM `table` WHERE `text` LIKE '%s but it should output: SELECT * FROM `table` WHERE `text` LIKE '%test%' 回答1: ... LIKE '%%%s%%'", mysql_real_escape_string('test')); To print the % character you need to escape it with itself. Therefore the first two %% will print the % character, while the third one is for the type specifier %s . You need a double %% at the end as

Does wildcard in left-most column of composite index mean remaining columns in index aren't used in index lookup (MySQL)?

▼魔方 西西 提交于 2019-12-31 07:27:06
问题 Imagine you have a primary composite index of last_name,first_name . Then you performed a search of WHERE first_name LIKE 'joh%' AND last_name LIKE 'smi%' . Does the wildcard used in the last_name condition mean that the first_name condition will not be used in further helping MySQL find indexes? In other words, by putting a wildcard on the last_name condition MySQL will only do a partial index lookup (and ignores conditions given in the columns that are to the right of last_name)? Further

LINQ to Entities using the SQL LIKE operator

爱⌒轻易说出口 提交于 2019-12-30 20:17:45
问题 I have this: query = query.Where(s => s.ShowTypeDescription == showTypeDescription); several times for different variables in order to build dynamic SQL. How would I go about transforming the above to say: query = query.Where(s => s.ShowTypeDescription **LIKE** showTypeDescription); ? 回答1: If all you want is to find a substring within another string, the best way to do this is with the Contains method: query = query.Where(s => s.ShowTypeDescription.Contains(showTypeDescription)); Because the

Oracle execution plans when using the LIKE operator with a DETERMINISTIC function

梦想的初衷 提交于 2019-12-30 11:32:22
问题 Now I have a really tricky thing with Oracle execution plans running havoc, when I use a DETERMINISTIC function on the right hand side of the LIKE operator. This is my situation: The Situation I thought it to be wise to execute a query like this (simplified): SELECT [...] FROM customers cust JOIN addresses addr ON addr.cust_id = cust.id WHERE special_char_filter(cust.surname) like special_char_filter(?) And I would bind ? to something like 'Eder%' . Now customers and addresses are very large

MYSQL: SELECT Method - but don't show duplicates / GROUP or DISTINCT?

懵懂的女人 提交于 2019-12-30 08:12:10
问题 How can I select and don't show duplicates? Actually, it's showing like that: apple | apple | apples | apple This is my code: $search = $_GET['q']; $query = "SELECT * FROM query WHERE searchquery LIKE '%$search%' AND searchquery <> '$search'"; 回答1: You already said the magic word: DISTINCT. SELECT DISTINCT columnname FROM query WHERE .... Note that it probably won't work if you use SELECT DISTINCT * because when you select * that means select all columns, including columns which have a unique

MYSQL: SELECT Method - but don't show duplicates / GROUP or DISTINCT?

拜拜、爱过 提交于 2019-12-30 08:11:58
问题 How can I select and don't show duplicates? Actually, it's showing like that: apple | apple | apples | apple This is my code: $search = $_GET['q']; $query = "SELECT * FROM query WHERE searchquery LIKE '%$search%' AND searchquery <> '$search'"; 回答1: You already said the magic word: DISTINCT. SELECT DISTINCT columnname FROM query WHERE .... Note that it probably won't work if you use SELECT DISTINCT * because when you select * that means select all columns, including columns which have a unique

MS Access SQL LIKE query from C#

狂风中的少年 提交于 2019-12-30 06:54:30
问题 I have this query for Ms Access and im using C# and Ole DB commands. It works on Ms Access but when I'm passing the query from C# using OleDB, nothing happened. Anyway here's my code: SQL query SELECT * FROM tblIssue WHERE id LIKE '*2*' AND dateChecque LIKE '**'AND + issueTo LIKE '**' AND byTheName LIKE '**' AND bankName LIKE '**' AND accountNo LIKE '**' + AND checqueNo LIKE '**' AND amount LIKE '**' AND being LIKE '**' AND whoDeleted LIKE '**' + AND whyDeleted LIKE '**' AND dateCreated LIKE

PostgreSQL: Select data with a like on timestamp field

我们两清 提交于 2019-12-29 11:47:09
问题 I am trying to select data from a table, using a "like" on date field "date_checked" (timestamp). But I have this error : SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: timestamp without time zone My request is : SELECT my_table.id FROM my_table WHERE my_table.date_checker LIKE '2011-01-%' I don't want to use : SELECT my_table.id FROM my_table WHERE my_table.date_checker >= '2011-01-01 00:00:00' AND my_table.date_checker < '2011-02-01 00:00:00' 回答1: It's all very well