Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
tommoe
Starting Member
2 Posts |
Posted - 2008-08-15 : 08:06:55
|
| When writing the WHERE and AND criteria, how do you code a condition to check if data actually exists in a table. Example: " WHERE RDS_MEMBER_INDIVIDUAL.MRIND_JOINED_DATE= ","'",SUNDATE,"'": " AND RDS_MEMBER_INDIVIDUAL.MRIND_INDIVIDUAL_KEY=RDS_ACTIVITY_ENROLLED_INDIVIDU.MRIND_INDIVIDUAL_KEY ": " AND RDS_ACTIVITY_ENROLLED_INDIVIDU.ACMAS_ACTIVITY_ID=RDS_ACTIVITY_MASTER.ACMAS_ACTIVITY_ID": " AND RDS_MEMBER_INDIVIDUAL.MRMAS_FAMILY_NUMBERKEY=RDS_MEMBER_ADDRESS_PRIMARY.MRADD_FAMILY_NUMBER " " OR RDS_MEMBER_INDIVIDUAL.MRMAS_FAMILY_NUMBERKEY=RDS_MEMBER_ADDRESS_ALTERNATE.MRADD_FAMILY_NUMBER "The last table RDS_MEMBER_ADDRESS_ALTERNATE may or may not exist for an individual.Also, please forgive the wrapping. |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2008-08-15 : 08:12:20
|
| use IF EXISTS ( <insert your select statement here>)-------------Charlie |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2008-08-15 : 08:14:10
|
| Actually I think you might want a LEFT JOIN.What do you mean : RDS_MEMBER_ADDRESS_ALTERNATE might not exists for an individual?Do you mean the table exists but that individual has no relevent data in it? Or are your tables dynamically generated somehow?More info please.-------------Charlie |
 |
|
|
tommoe
Starting Member
2 Posts |
Posted - 2008-08-15 : 08:57:59
|
thanks. I'll try that.quote: Originally posted by Transact Charlie Actually I think you might want a LEFT JOIN.What do you mean : RDS_MEMBER_ADDRESS_ALTERNATE might not exists for an individual?Do you mean the table exists but that individual has no relevent data in it? Or are your tables dynamically generated somehow?More info please.-------------Charlie
|
 |
|
|
|
|
|