Quality is delighting customers
create dept table(deptno,dname,loc)
create emptable(eno,ename,job,sal,deptno) using primary,refernce key
select empno,ename,job,sal,deptno from emp where
deptno in (select deptno from dept
where loc = 'CHICAGO');
data retrive from two tables with out using joins
In this query we can say that we are using two different tables to retrieve the data; but we are retrieving the data (empno, ename,job,sal,deptno) only from one table viz emp and not from dept. Let me know your thoughts.
you can try something like this though...
Select emp.ename, dept.dname from emp, dept where emp.eno in (Select eno from emp)
ahh.. I guess this is the answer to the original question. I tried and it works.
nice explain. Between join, sub query & nested query, who will give fast result?
Thanks all of you.
I have one more question, We can retrieve data from 2 tables using alias/nested queries & Joins.
Both are retrieving same data then what is the difference between alias/nested queries & Joins?
gud questions plz arvi i need answer of this question too
With Alias - we can alias a name to a column or table and retrieve the data from 2 tables.
Joins- We can retrieve data from more than 2 tables.
With Alias also we can retrieve the data then why we use Joins? pls.. explain clearly. Bcoz this question is asked in one interview.
Using Alias - Implicit joins
Using Joins - Explicit joins
Both are joins only, but different join notions. The only way to retrieve from 2 tables is using sub queries. I have specified the query above.
mysql> SELECT * FROM officeTable WHERE Empid in(SELECT Empid FROM employee); is this what you are looking for?