Author |
Topic |
Ravius
Starting Member
13 Posts |
Posted - 2009-11-22 : 21:50:15
|
Hi guys, im still learning this. hope you guys can help me out (:I have 2 tables, "property" and "favourites".the "property table" includes propertyid and the detailswhereas the "favourites table" include buyerID and propertyidI need to select all the details from the "property table" where the propertyid matches the propertyid in the "favourites table" that matches a particular buyeridlet say in the "favourites table", buyerid 5 is linked with propertyid 2,3,5,7. I will need to display details of property with id 2,3,5,7Sorry if i made it very complication >.< Thanks all of you in advance =D |
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2009-11-22 : 21:57:52
|
[code]SELECT p.*FROM [property] pJOIN [favourites] fOn f.propertyid = p.propertidWHERE f.buyerid = xxx[/code] |
 |
|
Ravius
Starting Member
13 Posts |
Posted - 2009-11-22 : 22:07:48
|
hey russell thank you so much!! =D really appreciate that |
 |
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2009-11-22 : 22:19:41
|
You're welcome. Glad to help! |
 |
|
Ravius
Starting Member
13 Posts |
Posted - 2009-11-23 : 03:01:28
|
Hey im sorry to bring this post up again... there are some changes made to the query.. sorry about that =Xi have another table call PropertyRemarks with BuyerID, PropertyID and comments...i need to link with the statement Russell had helped me earlier on to display the comments as well (: May i know how i can do that?? sorry for the trouble! |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-11-23 : 03:58:30
|
[code]SELECT p.*,r.commentsFROM [property] pJOIN [favourites] fOn f.propertyid = p.propertidJOIN PropertyRemarks as r on p.propertid=r.propertidWHERE f.buyerid = xxx[/code]MadhivananFailing to plan is Planning to fail |
 |
|
Ravius
Starting Member
13 Posts |
Posted - 2009-11-23 : 23:20:01
|
sorry madhivanan, its doesn't seems to display what i need. #################TableProperty-PropertyID-*Favourites-BuyerID-PropertyIDComments-BuyerID-PropertyID-remarks#################I have 3 tables and their properties are stated above. Firstly buyer set a property to Favourites and then add comment to itI need to display the details of the Favourited properties and its comment in a table.Both the Favourites and Comments table need to take in a BuyerID. |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-11-25 : 00:57:24
|
quote: Originally posted by Ravius sorry madhivanan, its doesn't seems to display what i need. #################TableProperty-PropertyID-*Favourites-BuyerID-PropertyIDComments-BuyerID-PropertyID-remarks#################I have 3 tables and their properties are stated above. Firstly buyer set a property to Favourites and then add comment to itI need to display the details of the Favourited properties and its comment in a table.Both the Favourites and Comments table need to take in a BuyerID.
Then alter the statement accordinglyMadhivananFailing to plan is Planning to fail |
 |
|
wayne.zjw
Starting Member
10 Posts |
Posted - 2009-12-23 : 15:58:00
|
select * from property table p1,favorites table p2 where p1.propertyid=p2.propertyidmaybe it can help you good luck |
 |
|
|