
- Forum
- Databases
- SQL Output without the JOIN condition. How is it possible ?
-
Output without the JOIN condition. How is it possible ?
I have two tables. Is it required to write join condition to retrieve the data from both?
But when I wrote a select statement like select end_date, account from detail, custom I got the output, in which end_date is from detail and account is from custom table.
Without join condition also can we retrieve the data? I got the output without the JOIN condition. How is it possible ?
Question asked by visitor raja
-
Re: Output without the JOIN condition. How is it possible ?
How is it possible to retrive data from more than one table with out join.
R u using any sub -query.
-
Expert Member
Re: Output without the JOIN condition. How is it possible ?
you have used sub-query in your select clause. It would be something like
select d.end_date, (select c.account from custom c where c.a=d.a)
from detail d;
-
Expert Member
Re: Output without the JOIN condition. How is it possible ?
Yes it is possible. Suppose there are 2 tables employees and orders employees: orders: emp_id emp_name prod_id product emp_id 01 a 234 printer 01 02 b 657 table 03 03 c 865 chair 04 04 d now select the emp_name and product with out using join: select employees.emp_name, orders.product from employees,orders where employees.emp_id=orders.emp_id using join: select employees.emp_name,orders.product from employees innerjoin orders on employees.emp_id=orders.emp_id output will be same for both quiries.
-
Expert Member
Re: Output without the JOIN condition. How is it possible ?
Yes it is possible. Suppose there are 2 tables employees and orders employees: orders: emp_id emp_name prod_id product emp_id
01 a 234 printer 01 02 b 657 table 03 03 c 865 chair 04
04 d now select the emp_name and product with out using join: select employees.emp_name, orders.product from employees,orders where employees.emp_id=orders.emp_id using join: select employees.emp_name,orders.product from employees innerjoin orders on employees.emp_id=orders.emp_id output will be same for both quiries.
-
Expert Member
Re: Output without the JOIN condition. How is it possible ?
Yes It is possible.
Suppose there are 2 tables Employees and Orders
Employees:
Emp_Id Emp_Name
01 A
02 B
03 C
04 D
Orders:
Prod_Id Product Emp_Id
234 Printer 01
657 Table 03
865 Chair 04
Now Select the Emp_Name and Product With out using Join:
select Employees.Emp_Name, Orders.Product from Employees,Orders where Employees.Emp_Id=Orders.Emp_Id
Using Join:
select Employees.Emp_Name,Orders.Product from Employees innerJoin Orders ON Employees.Emp_Id=Orders.Emp_Id
OutPut will be same for both quiries.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules