|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
i have a table1 having userid(primary key) and username. I have another table2 having senderid, receiverid fields referring to userid of table1. Now i have created a view wherein the condition i have used is:
where table2.senderid = table1.userid and table2.receiverid = table1.userid. the problem is this code will give me only those rows where both senderid and receiverid are same. I have tried using joins also but didn't get proper result. Can anyone tell me how to get through this? |
|
#2
|
||||
|
||||
|
This has nothing to do with foreign keys, you need to join two times on the users table using an alias, something likeI suggest also to use the inner join syntax instead of the where syntax for joins
__________________
My blog Tutorials about OSS databases, DBMonster ... Contribute to OSS Development, fill bug reports! Developer Shed eSupport Commented my.ini/my.cnf (ADD YOUR OWN CONFIG TRICK) An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries Don't turn your outer joins into inner joins Random data (with a bias) |
|
#3
|
|||
|
|||
|
Thank You
Quote:
THANKS A LOT. IT'S WORKING VERY WELL.......... |
![]() |
| Viewing: Dev Shed Forums > Databases > Firebird SQL Development > Two foreign keys of a table referring a same primary key |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|