Re: Is there a unique like?
Posted by: Mario Levesque
Date: January 09, 2012 07:32PM

I know this is an old entry (more than 2 month old), but i just don't understand what you ask for :

You ask for a UNIQUE LIKE, but then, you describe a requirement that output multiple rows.

> What i need is:

>If there are rows with entries abc,dsa abc, abcd etc when I select i have to get abc, and dsa abc rows.

The following query : "SELECT * FROM database WHERE data LIKE '%abc%'"

on a database like this:

+=====+=============+
| id | data |
+=====+=============+
| 1 | abc |
| 2 | dsa abc |
| 3 | abcd |
+=====+=============+

would match everything in the database since the wildcards you used ('%abc%') matches all the entries.

Now to match your requirements, that is :

>If there are rows with entries abc,dsa abc, abcd etc when I select i have to get abc, and dsa abc rows.

I would use the following query : "SELECT * FROM database WHERE data LIKE '%abc'",
which would output this :

+=====+=============+
| id | data |
+=====+=============+
| 1 | abc |
| 2 | dsa abc |
+=====+=============+

because the wildcard is placed BEFORE the string. It basically means "Match anything before my string including spaces"

I hope that its what you've been looking for.

Options: ReplyQuote


Subject
Written By
Posted
November 29, 2011 10:01PM
Re: Is there a unique like?
January 09, 2012 07:32PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.