Home » SQL & PL/SQL » SQL & PL/SQL » LIKE condition
LIKE condition [message #242213] Fri, 01 June 2007 01:56 Go to next message
sjaiswal
Messages: 31
Registered: September 2006
Location: Mumbai
Member
Hi,
I have written a query where there are three LIKE conditions.
Please let me know if this is the correct way or if I can write it in more compact way. I have written LIKE three times using OR. Is there any other way where I can reduce this to one line for the LIKE statement.

SELECT item, transdesc, week1_qty, week2_qty
        FROM table1
       WHERE transdesc LIKE 'Supply - P%'
	  OR transdesc LIKE 'Supply - F%'
	  OR transdesc LIKE 'Qty con%'


Regards,
Sjaiswal
Re: LIKE condition [message #242221 is a reply to message #242213] Fri, 01 June 2007 02:25 Go to previous messageGo to next message
Michel Cadot
Messages: 64120
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
This is the correct way.

Regards
Michel
Re: LIKE condition [message #242223 is a reply to message #242213] Fri, 01 June 2007 02:34 Go to previous messageGo to next message
Frank Naude
Messages: 4502
Registered: April 1998
Senior Member
If you are on 10g, use

WHERE REGEXP_LIKE(transdesc, '^Supply - F|^Supply - P|^Qty con')
Re: LIKE condition [message #242224 is a reply to message #242223] Fri, 01 June 2007 02:36 Go to previous message
Michel Cadot
Messages: 64120
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
I don't think this is good for performances. Wink

Regards
Michel
Previous Topic: PLS-00364 while creating a procedure
Next Topic: returning multiple records as a parameter
Goto Forum:
  


Current Time: Tue Dec 06 12:20:44 CST 2016

Total time taken to generate the page: 0.09940 seconds