SQL query problem - help needed pls [message #2648] |
Fri, 02 August 2002 23:45 |
Prabha R
Messages: 21 Registered: October 2001
|
Junior Member |
|
|
Hi,
I have two tables as follows:
ReportUsers
-----------
Userid char(10)
opco char(15)
Sample data
-----------
k_gopi CPDN,CPL
rprabha ALL
OpcoMapping Table
-----------------
opcocode Char(50)
opco char(50)
name char(50)
Sample data
-----------
0061 CPDN XXXYYZZ
0323 CPL yyyyyyy
0021 NAFSC UUCCCYY
I need to find the opcocode and name for all opco's of a particular userid and display it. Hence i wrote a query like:
"select opco||opcocode||name from ediopcomapping where opco in (select opco from ediReportUsers where Userid= 'k_gopi')"
Eventhough there are rows for opco CPDN and CPL, this query returned "NO ROWS".
OPCO field in ReportUsers table and opco field in Opcomapping table are of same datatype. Hence i thought, the above query is ok. But since it is not returning any rows, i doubt whether the values returned by the sub query is not like 'CPDN','CPL'.
Can anybody help me in getting this work. Any immediate help is greatly appreciated.
Thanks and Regards,
prabha
|
|
|
Re: SQL query problem - help needed pls [message #2649 is a reply to message #2648] |
Sat, 03 August 2002 03:23 |
|
Mahesh Rajendran
Messages: 10707 Registered: March 2002 Location: oracleDocoVille
|
Senior Member Account Moderator |
|
|
your query and this query should work!.
select a.opco,a.opcocode,a.name from
ediopcomapping a, edireportusers b
where a.opco=b.opco;
But, you are using char as the datatype in opco.
so 'CPL' AND 'CPL ' will be treated as different data.
check that out!
|
|
|