Quality Testing

Quality is delighting customers

How can we retrieving data from multiple tables without using SELECT in mysql?

Hi,

How can we retrieve data from 2 tables without using Joins in mysql?

Mythri

Views: 3952

Reply to This

Replies to This Discussion

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.

 

Regards,

Arvi, QTPhelp.com

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.

Hi,

nice explain. Between join, sub query & nested query, who will give fast result?

Hi,

 

Thanks all of you.

 

@Arvi,

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

 

Nested : Nested query is using the results of a subquery in the main query (A Query inside a query)

Alias:http://www.w3schools.com/sql/sql_alias.asp

Joins : http://www.w3schools.com/sql/sql_join.asp

 

Regards,

Arvi, 

Check out how to Connect to database using QTP

 

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?

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2022   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service