Home » SQL & PL/SQL » SQL & PL/SQL » Oracle SQL - Parameter in where condition to search two values from one
Oracle SQL - Parameter in where condition to search two values from one [message #649616] Fri, 01 April 2016 03:40 Go to next message
azocomposto
Messages: 2
Registered: May 2010
Junior Member
Hi all,
I have this case: In my database, the companys are identified in the I_COMPANY table with a unique code in IC_COMPANY_CODE column and a description in IC_COMPANY_DESC column.

Example of records:

The IC_COMPANY_DESC = 'ATLANTA', is identified by two IC_COMPANY_CODE = 901 and 902.
The IC_COMPANY_DESC = 'TORONTO', is identified by two IC_COMPANY_CODE = 903 and 904.
In this example query SQL, in the WHERE condition I want insert a parameter :IC_COMPANY_CODE = '901' and the query search result, must display in a dataset 901 and 902 records, how to write this query?

SELECT IC_COMPANY_CODE, IC_COMPANY_DESC
FROM I_COMPANY
WHERE IC_COMPANY_CODE  = :IC_COMPANY_CODE -- > how to insert 901 string and display result for 901 and 902?


How can I resolve this problem?

Thanks
Re: Oracle SQL - Parameter in where condition to search two values from one [message #649617 is a reply to message #649616] Fri, 01 April 2016 03:45 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Join i_company to itself on ic_company_desc.
Re: Oracle SQL - Parameter in where condition to search two values from one [message #649624 is a reply to message #649617] Fri, 01 April 2016 05:53 Go to previous message
JNagtzaam
Messages: 36
Registered: July 2015
Location: Alkmaar
Member

Basicly the same:

SELECT ic_company_code
      ,ic_company_desc
  FROM i_company
 WHERE ic_company_desc = (SELECT ic_company_desc FROM i_company WHERE ic_company_code = :ic_company_code)


You will probably need an index on ic_company_desc.
Previous Topic: Can RESULT_CACHE be used in a Package Function?
Next Topic: Subtracting dates
Goto Forum:
  


Current Time: Fri Apr 26 01:07:12 CDT 2024