selection from more than two tables [message #237639] |
Tue, 15 May 2007 05:21 |
vamsikgummadi
Messages: 62 Registered: April 2006 Location: United States, MI
|
Member |
|
|
Hello to ORAFAQ members,
Please find out the solution for the following
problem if possible.I am designing a website and I have the following tables in my database[the
columns are mentioned in the braces]
•LOGIN TABLE [login(primary key), password,password_hint]
•USERTABLE[login, u_image_url, socialstatus,education, address, contact]
•FRIENDSTABLE[friend_login,friend_name,nick_name,f_image_url,u_scraps,login]
•VISITORSTABLE[visitor_login, visitor_name,visitor_image_url,v_scraps, login]
--login is a common column in all these tables.
Requirement:
I want to retrieve
1.login from LOGINTABLE
2.u_image_url from USERTABLE
3.friend_login, friend_name, f_image_url, u_scraps from FRIENDSTABLE
4.visitor_login, visitor_name, visitor_image_url,
v_scraps from VISITORSTABLE.
All these values need to be retrieved by using SQL,
this is similar to the Orkut home page scenario.
You can make small changes to the tables if required
but my requirement must not be changed.
The scraps of friends and visitors should be in the
same table and this is the main requirement.
Thanking you in anticipation,
VamsiKGummadi.
|
|
|
|
Re: selection from more than two tables [message #237648 is a reply to message #237639] |
Tue, 15 May 2007 06:22 |
apps.suresh
Messages: 15 Registered: October 2006
|
Junior Member |
|
|
may be this helps you...
this is the query to retrieve the date u want....
select login
, ut.u_image_url
, ft.friendlogin
, ft.friendname
, ft.f_image_url
, ft.u_scraps
, vt.visitorlogin
, vt.visitorname
, vt.visitor_image_url
, vt.v_scraps
from logintable lt
, usertable ut
, friendstable ft
, visitorstable vt
where lt.login = ut.login
and lt.login = ft.login
and lt.login = vt.login
and lt.login like '12345'
regards
suresh
|
|
|
|
|
|
|
|
|
Re: selection from more than two tables [message #237841 is a reply to message #237641] |
Tue, 15 May 2007 23:46 |
vamsikgummadi
Messages: 62 Registered: April 2006 Location: United States, MI
|
Member |
|
|
Hello all,
Thank you for the help but all the efforts went in vain. I am uanble to retrieve the data as required .Still there is duplication of values in some of the columns which is to be avoided.I have tried all your hints and queries.Some of you suggested to use joins if necessary, can you please type the code for me.
I thank you all for the trials you have made to help me to figure out the problem.
Regards,
VamsiK Gummadi.
|
|
|
Re: selection from more than two tables [message #237866 is a reply to message #237841] |
Wed, 16 May 2007 00:57 |
William Robertson
Messages: 1643 Registered: August 2003 Location: London, UK
|
Senior Member |
|
|
vamsikgummadi wrote on Wed, 16 May 2007 05:46 | Thank you for the help but all the efforts went in vain. I am uanble to retrieve the data as required .Still there is duplication of values in some of the columns which is to be avoided.I have tried all your hints and queries.Some of you suggested to use joins if necessary, can you please type the code for me.
|
"Joins if necessary"? Surely you decide whether or not joins are necessary besed on your data model? What are the unique and foreign key definitions? Some same data would help as well (in [code] tags, please.) Anyway, some code has already been posted. All we know is there is "some duplication in some of the columns". How can anyone know what to change in the query based on that information?
vamsikgummadi wrote | All these values need to be retrieved by using SQL, this is similar to the Orkut home page scenario. You can make small changes to the tables if required
but my requirement must not be changed. The scraps of friends and visitors should be in the same table and this is the main requirement.
|
I have no idea what the Orkut home page scenario is, or what you mean by "scraps of friends and visitors", or how else you could retrieve anything from Oracle other than by using SQL.
Can we remove the word "TABLE" from all of the table names?
[Updated on: Wed, 16 May 2007 01:01] Report message to a moderator
|
|
|
Re: selection from more than two tables [message #238005 is a reply to message #237866] |
Wed, 16 May 2007 05:58 |
vamsikgummadi
Messages: 62 Registered: April 2006 Location: United States, MI
|
Member |
|
|
Hello Mr.William Robertson,
Yes, you can remove the word table from all these table names for convenience.The main purpose of the query is retrieve scraps from visitors and friends in a single table or view by suppling an input.The input value is something similar to login.I hope I am clear with my doubt .Please get bak if you need some other clarification regarding this doubt.
Vamsi K Gummadi.
|
|
|