Solved

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

Posted on 2008-10-10
5
309 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 143

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 143

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What's wrong with this T-SQL Foreign Key? 7 51
Query Help - MSSQL - Averages 5 30
SQL Error - Query 6 41
SQL Syntax Grouping Sum question 7 27
Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

829 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