sql-like

How to combine “LIKE” with “IN” in a MYSQL query?

自闭症网瘾萝莉.ら 提交于 2019-12-07 14:16:17
问题 I have this code to search for a matching result in a MYSQL database: $where[] = 'p.id IN ( SELECT adcfvc.advert_id FROM #__koparent_advert_specific_fields_values AS adcfvc WHERE adcfvc.advert_id = p.id AND adcfvc.field_name = ' . $db->Quote($sf_key) . ' AND ' . $db->Quote(JString::strtolower($sf_value)) . ' = adcfvc.field_value )'; I want to change the above search query from selecting exact match using the equal sign "=" operator to selecting any matching result using the "LIKE" operator

Repeating characters in T-SQL LIKE condition

一世执手 提交于 2019-12-07 13:33:42
问题 Problem: Limit the value of a VARCHAR variable (or a column) to digits and ASCI characters, but allow variable length. This script will not yield required result: declare @var as VARCHAR (150) select @var = '123ABC' if (@var LIKE '[a-zA-Z0-9]{0,150}') print 'OK' else print 'Not OK' Anyone have idea how to do this? 回答1: You can do this with the not carat ^, and a NOT LIKE expression. So you say, where not like not non-alphanumeric ;) This works for standard numbers & characters: declare @var

PHP way to execute SQL LIKE matching without a database query?

て烟熏妆下的殇ゞ 提交于 2019-12-07 12:08:32
问题 I want to match an input string to my PHP page the same way a match done by the LIKE command in SQL (MySQL) for consistency of other searches. Since (I have seen but don't comprehend) some of the PHP syntax includes SQL commands I am wondering if this is possible? The reason for this is I am now implementing a search of a keyword versus fields in the DB that are stored in a serialized array, which I have to unserialize in PHP and search depending on the structure of the array. I can't query

Emulate a SQL LIKE search with ElasticSearch

流过昼夜 提交于 2019-12-07 06:05:40
问题 I'm just beginning with ElasticSearch and trying to implement an autocomplete feature based on it. I have an autocomplete index with a field city of type string . Here's an example of a document stored into this index: { "_index":"autocomplete_1435797593949", "_type":"listing", "_id":"40716", "_source":{ "city":"Rome", "tags":[ "listings" ] } } The analyse configuration looks like this: { "analyzer":{ "autocomplete_term":{ "tokenizer":"autocomplete_edge", "filter":[ "lowercase" ] },

How should I escape characters inside this LIKE query?

独自空忆成欢 提交于 2019-12-07 05:02:41
问题 I have a field in one of my tables that contains this string: !"#¤%&/()=?´`?=)(/&%¤#"!\'\'"' (Only for test purposes ofcourse). I've tried endless of queries to properly select this field, and without returning any errors of course, but I just can't seem to get it right. This is the query I'm using currently: SELECT * FROM mytable WHERE `column` LIKE '%!"#¤%&/()=?´`?=)(/&%¤#"!\\\'\\\'"\'%' Can anyone shed some light on what it is I'm not doing right? Are there any other characters (other than

LIKE operator, N and % SQL Server doesn't work on nvarchar column

我与影子孤独终老i 提交于 2019-12-06 22:36:25
Is there any way to make following query Work? declare @t nvarchar(20) set @t='حس' SELECT [perno] ,[pName] FROM [dbo].[People] Where [pName] like N''+@t +'%' I cann't use like this: Where [pName] like N'حس%' Or using an stored procedure : ALTER PROCEDURE [dbo].[aTest] (@t nvarchar(20)) AS BEGIN SELECT [perno] ,[pName] FROM [dbo].[People] WHERE ([People].[pName] LIKE N'' +@t + '%') END You don't need to use N prefix in the WHERE clause since your variable is already nvarchar , and you are passing a variable not a literal string . Here is an example: CREATE TABLE People ( ID INT, Name NVARCHAR

How to use LIKE statement in sql plus with multiple wild carded values?

筅森魡賤 提交于 2019-12-06 15:43:29
my question is that currently if i want to query for multiple wildcarded values. I need to do something like this. select customername from customers where customername like '%smith' or customername like '%potter' or customer name like '%harris' or customername like '%williams'; So I wanna ask from the experts, is there any easier way to do this? Regards, Sanjan Create a table of your 100 names select customername from customers c inner join customersames cn on(c.customernamename like '%'+cn.searchForname) Can be a table variable if that helps. you can use regular expressions EDIT: You can

PHP PDO LIKE : escaping the % character when combining with wildcard

怎甘沉沦 提交于 2019-12-06 10:53:32
问题 $percent = ‘%’; $st=$db->prepare(“SELECT * FROM x WHERE y LIKE ?”); $st=$st->execute(array(‘%’.$percent.’%’)); /*I want to get all records with the string % included like 5% etc.*/ The above example will not match correctly, instead matching all records in table x. In order for this to work correctly, I apparently need to set $percent='\%'. This is where I am left confused about the concept behind prepared statements. I thought the whole point of prepared statements was that the value itself(

Using LIKE to match floats when Rounding is not wanted

 ̄綄美尐妖づ 提交于 2019-12-06 10:29:10
So here is what I am trying to accomplish. I have coordinate data in two tables, which I am trying to link together with an Association table. It is a one to one association, so if I have 40 records in table A, 40 records in table B, then I should have 40 records in the association table. Now the data in these two tables is approximately the same, but never idential, in fact they rarely even have the same precision. One table(we'll say A) always has 6 decimal places, whereas table B may have no decimal places or up to 6 decimal places. So let's say we're just matching up one pair of data, say,

Using LIKE in a JOIN query

喜你入骨 提交于 2019-12-06 10:01:35
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 get a result or match. Is this possible using LIKE or LEFT ? It probably is, though this might depend on