Solved

can anyone explain how can i write this query in sql?

Posted on 2008-10-10
5
290 Views
Last Modified: 2012-05-05
hi ,
i have three tables customer , property and saved property table
when i save property then P_Id and C_ID get saved inside savedproperty table
when i retrive from table i get C_Id from session and P_Id where C_Id=@C_Id from savedproperty  table
but i want to retrive all the information with that corresponding P_Id from proeprty table how can i do that ?
0
Comment
Question by:devilsuraj
  • 2
5 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 22685342
you mean:
SELECT c.*, p.*
  FROM customer c
  JOIN saved_property cp
    ON cp.C_ID = c.C_ID
  JOIN property p
    ON p.P_ID = cp.P_ID
 WHERE c.C_ID = @C_ID

Open in new window

0
 

Author Comment

by:devilsuraj
ID: 22685396
thanks
yes something like this but i didn't understand what you did here

my tables name and columns name are as follow

customer table = custTbale
primary id = C_Id
secondary id = username

property table = propertyTable
primary id = P_Id

saved property = saveSearchTable
primary id = S_Id

but i use session username for retriving details so please show me somthing with this please
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 22685406
still the same:
SELECT c.*, p.*

  FROM customer c

  JOIN saved_property cp

    ON cp.C_ID = c.C_ID

  JOIN property p

    ON p.P_ID = cp.P_ID

 WHERE c.username = <session_user_name>

Open in new window

0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A publishing tool, a Version Control System, or a Collaboration Platform! These can be some of the defining words for the two very famous web-hosting Git repositories: Bitbucket and Github. Git is widely used amongst the programmers and developers f…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This video teaches users how to migrate an existing Wordpress website to a new domain.
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now