Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question on select

 
Adi Peyyala
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does a query like this execute:

select * from tablename1, tablename2

tablename1 and tablename2 are two different tables with different schemas.

Adi
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Adi Peyyala:
Does a query like this execute:

select * from tablename1, tablename2

tablename1 and tablename2 are two different tables with different schemas.

Adi


Why didn'y you try this ?

answer is yes !!

If your tablename1 has 10 rows and tablename2 has 5 rows then you will get 50 rows in result with all columns of both table.

Shailesh
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More specifically it's a cross product of two tables.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Srinivasa Raghavan:
More specifically it's a cross product of two tables.


And technically its Cartesian Product. You need join between tables.
 
s choukse
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use This to select all columns from both tables.
You will have to join the tables on proper columns to avoid cartesian product.

select tablename1.*, tablename2.* from tablename1, tablename2
where tablename1.col1 tablename2.col1;

Let me know.

s choukse
 
Kareem Qureshi
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

select * from tablename1, tablename2
tablename1 and tablename2 are two different tables with different schemas.


if you mean they belong to two different databases then
You cannot do a select on two different schemas.

Hope this clarifies

Thanks
Kareem
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic