1

I am running my Oracle query here but it's not working but the same query is working in SQL Server

Here is my query:

SELECT d.dept_code,
       d.dept_name,
       d.dept_desc,
       e.comp_name
FROM   dept_master d
       inner join comp_master e
               ON d.comp_id = e.comp_id 

where in dept_master.comp_id value is the same as in Dept_Master table.

5
  • 3
    What is the Error you are getting? Commented Sep 14, 2012 at 7:41
  • Not getting any value only column name is showing. Commented Sep 14, 2012 at 7:49
  • can you please update your code like this stackoverflow.com/questions/6559261/… Commented Sep 14, 2012 at 7:54
  • 2
    if you're not getting any results then that means either you join condition is wrong or there are no records matching the join condition Commented Sep 14, 2012 at 7:58
  • can give the table structures? like using 'desc dept_master' command Commented Sep 14, 2012 at 10:56

2 Answers 2

1

The reason you are not getting any result is mainly because of the data

do this check to see if data is available in the tables

select * from dept_master;
select * from comp_master;

and see if both tables have any matching rows, i.e.; at least 1 row has same comp_id in both tables

I hope you will find the answer after doing this exercise

Sign up to request clarification or add additional context in comments.

2 Comments

sir data is there in both tables but when i am fetching comp_id then it's containing some space and through that i am not able to join the query.
@Vikash do you whitespaces in comp_id?
1

Is comp_id a character field? In that case define it as VARCHAR2 in Oracle. or try trim(d.comp_id) = trim(e.comp_id)

See a demonstration in SQL Fiddle.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.