Question about how to know how many rows in the result will I get in SQL?

On the exam there will be questions ask me to predit how many rows and coolumns will a statement output.

There will be like 3 join statements in the result table.

Can I assume that the amount of rows is really determined by the first join statement? If the first join statement only output 7 rows then no matter what happen in the next 2 join statements the whole result will just have 7 rows and whatever column it picked.

the statements will be something like this:

SELECT ord3.orderID,

OrderDate,

DueDate,

CustomerName,

EmpName

FROM ord3

LEFT OUTER JOIN cust

ON ord3.custid = cust.custid

INNER JOIN emp3

ON ord3.empid = emp3.empid

1 Answer

Relevance
  • John
    Lv 7
    1 month ago
    Favorite Answer

    Number of row return depends on employee join.

    select * from [ord3] returns 7 rows

    if [ord3].custid does not exist in [cust] table the joined columns would be shown as NULL when join

    if [ord3].empid does not exist in [emp3] table the ROW would NOT be shown when join

    you have to understand the nature of joins to answer this answer.

    • Login to reply the answers
Still have questions? Get your answers by asking now.