Skip to Content
author's profile photo Former Member
Former Member

Query regarding inner join

Hi,

I have below two tables.

table1

ID Desc 1 abc 2 def 3 ghi 4 jkl

table2

ID Revenue 1 100 1 200 1 300 2 400 2 401 2 402 3 403 3 404 3 405 4 406 4 407 4 408

i have executed below query.

select t."ID",t."Desc",t1."Revenue"

from "table1" as t

inner join "table2" as t1

on t."ID" = 1.0;

Result:

So my question is why its fetching records from table2 in which ID <> 1?

It should only fetch records from table 2 where ID = 1 only.

I think I am lacking my understanding in case of joins somewhere. 😔

Please explain.

BR

Sumeet

out.png (11.3 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Aug 18, 2015 at 07:11 PM

    Hello Sumeet

    You're doing a cross join between the tables, because you did not specify any join conditions between the two tables, just a condition on the first one.

    Try this:

    select t."ID",t."Desc",t1."Revenue"

    from "table1" as t

    inner join "table2" as t1

    on t."ID" = t1."ID"

    where t."ID" = 1.0;

    Regards

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.