Is there anyway to compare a field with multiple string values using
LIKE?
Here's the statement I have now:
SELECT * FROM list
WHERE email LIKE CONVERT( _utf8 'h******@hotmai l.com' USING latin1 )
OR email LIKE CONVERT( _utf8 'j***@hotmail.c om' USING latin1 )";
I know how to do it using the IN operator,
SELECT * FROM list
WHERE email IN ('h******@hotma il.com', 'j***@hotmail.c om')
but I need to be able to use the LIKE operator with the CONVERT
function. The reason I am asking is because I am trying to match 50+
different email addresses.
Anyway how to do this?
TIA 4 19827
Evil Bert wrote: Is there anyway to compare a field with multiple string values using LIKE?
Here's the statement I have now: SELECT * FROM list WHERE email LIKE CONVERT( _utf8 'h******@hotmai l.com' USING latin1 ) OR email LIKE CONVERT( _utf8 'j***@hotmail.c om' USING latin1 )";
I know how to do it using the IN operator, SELECT * FROM list WHERE email IN ('h******@hotma il.com', 'j***@hotmail.c om')
but I need to be able to use the LIKE operator with the CONVERT function. The reason I am asking is because I am trying to match 50+ different email addresses.
Anyway how to do this?
I don't understand why you need to use LIKE, since you aren't using any
wildcards in your examples above. So the usage of LIKE is simply
testing for string equality. You could replace the instances of LIKE
with the = sign and it work the same, as far as I know.
Anyway, no, the IN operator does strict equality comparisons, it has no
support for wildcards.
However, if you did need to do comparisons with wildcards against many
patterns, I would suggest loading the patterns into a temporary table,
joining your `list` table to that temp table, and then using LIKE in the
join condition.
Regards,
Bill K.
Doesn't the LIKE compare the string regardless of upper or lower case.
When using = the exact case is searched for. Correct me if I am wrong.
Thanks
On Thu, 20 Oct 2005 19:18:40 -0700, Bill Karwin <bi**@karwin.co m>
wrote: Evil Bert wrote: Is there anyway to compare a field with multiple string values using LIKE?
Here's the statement I have now: SELECT * FROM list WHERE email LIKE CONVERT( _utf8 'h******@hotmai l.com' USING latin1 ) OR email LIKE CONVERT( _utf8 'j***@hotmail.c om' USING latin1 )";
I know how to do it using the IN operator, SELECT * FROM list WHERE email IN ('h******@hotma il.com', 'j***@hotmail.c om')
but I need to be able to use the LIKE operator with the CONVERT function. The reason I am asking is because I am trying to match 50+ different email addresses.
Anyway how to do this?
I don't understand why you need to use LIKE, since you aren't using any wildcards in your examples above. So the usage of LIKE is simply testing for string equality. You could replace the instances of LIKE with the = sign and it work the same, as far as I know.
Anyway, no, the IN operator does strict equality comparisons, it has no support for wildcards.
However, if you did need to do comparisons with wildcards against many patterns, I would suggest loading the patterns into a temporary table, joining your `list` table to that temp table, and then using LIKE in the join condition.
Regards, Bill K.
Evil Bert wrote: Doesn't the LIKE compare the string regardless of upper or lower case. When using = the exact case is searched for. Correct me if I am wrong.
All string comparisons in MySQL are case-insensitive, unless by use of
the BINARY keyword they are made to be case-sensitive.
Try executing the following expressions:
SELECT 'abc' LIKE 'abc';
SELECT 'abc' LIKE 'ABC';
SELECT 'abc' LIKE BINARY 'abc';
SELECT 'abc' LIKE BINARY 'ABC';
SELECT 'abc' = 'abc';
SELECT 'abc' = 'ABC';
SELECT 'abc' = BINARY 'abc';
SELECT 'abc' = BINARY 'ABC';
SELECT 'abc' IN ('abc');
SELECT 'abc' IN ('ABC');
SELECT 'abc' IN (BINARY 'abc');
SELECT 'abc' IN (BINARY 'ABC');
See http://dev.mysql.com/doc/refman/5.0/...functions.html
for a reference.
Regards,
Bill K.
Thanks Bill, I just learned something new. I just thought the = equal
sign did an exact match. I guess it's from using PHP so much that I
thought this way...
Thanks again.
On Thu, 20 Oct 2005 21:28:54 -0700, Bill Karwin <bi**@karwin.co m>
wrote: Evil Bert wrote: Doesn't the LIKE compare the string regardless of upper or lower case. When using = the exact case is searched for. Correct me if I am wrong.
All string comparisons in MySQL are case-insensitive, unless by use of the BINARY keyword they are made to be case-sensitive.
Try executing the following expressions:
SELECT 'abc' LIKE 'abc'; SELECT 'abc' LIKE 'ABC'; SELECT 'abc' LIKE BINARY 'abc'; SELECT 'abc' LIKE BINARY 'ABC'; SELECT 'abc' = 'abc'; SELECT 'abc' = 'ABC'; SELECT 'abc' = BINARY 'abc'; SELECT 'abc' = BINARY 'ABC'; SELECT 'abc' IN ('abc'); SELECT 'abc' IN ('ABC'); SELECT 'abc' IN (BINARY 'abc'); SELECT 'abc' IN (BINARY 'ABC');
See http://dev.mysql.com/doc/refman/5.0/...functions.html for a reference.
Regards, Bill K. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Matthew Louden |
last post by:
I want to know why C# doesnt support multiple inheritance? But why we can
inherit multiple interfaces instead? I know this is the rule, but I dont
understand why. Can anyone give me some concrete examples?
|
by: Peter Kirk |
last post by:
Hi
I am looking at some code which in many places performs string comparison
using == instead of Equals.
Am I right in assuming that this will in fact work "as expected" when it is
strings involved? By "as expected" I mean that as long as the strings are
instantiated using string literals, then == and Equals are the same.
string s1 = "xxx";
|
by: spam.noam |
last post by:
Hello,
Guido has decided, in python-dev, that in Py3K the id-based order
comparisons will be dropped. This means that, for example, "{} < "
will raise a TypeError instead of the current behaviour, which is
returning a value which is, really, id({}) < id().
He also said that default equality comparison will continue to be
identity-based. This means that x == y will never raise an exception,
as is the situation is now. Here's his reason:
|
by: nitro_punk85 |
last post by:
I'm working on a project for my c++ class and I am having trouble
comparing one string to two others using the or operator. It looks
something like this:
if(answer3 == answer1 || answer2)
Is there another command I need to through in there or should I do it a
completely different way?
Any suggestions would be most appreciated.
|
by: eastern_strider |
last post by:
I'm running into problems about defining a comparison function for a
map which has a user defined key. For example:
class Key {
public:
string name;
int number;
Key (na, nu) : name (na), number (nu) {}
bool operator< (const Key &key) const; //my question is how to
| |
by: Gerard Kramer |
last post by:
Hello,
There is a slight problem with operator overloading in a program I
attempt to start practising C++. It is a basic (not very original) game
of life simulator. It uses two classes: LifeGeneration and LifeHistory.
Declarations are given by:
// Contents of file LifeGeneration.h
#ifndef LIFEGENERATION_H
|
by: Daz |
last post by:
Hello people!
(This post is best viewed using a monospace font).
I need to create a class, which holds 4 elements:
std::string ItemName
int Calories
int Weight
int Density
|
by: jorgedelgadolopez |
last post by:
Hi all,
I am using the xpathnavigator evaluate function on .net (xpath 1
right?). Now I need to expand the code to do multiple contains,
compare dates (such as 'before', 'between' and 'after'), and so on.
This is the thought:
//person
|
by: Andrus |
last post by:
I created dynamic extension methods for <= and < SQL comparison operators:
public static IQueryable<TLessThanOrEqual<T>(this IQueryable<Tsource,
string property, object value);
public static IQueryable<TLessThan<T>(this IQueryable<Tsource, string
property, object value);
For example
var q = db.Customers.LessThanOrEqual( "City", "London" );
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |