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 |
|
programer
Posting Yak Master
221 Posts |
Posted - 2011-12-12 : 12:52:30
|
| I have a table tbl_Details and tbl_DetailsEvents.Structuretbl_Details:Id, UserId, Amount, Winnings1, uuuu, 13.25 Lost tbl_DetailsEvents:Id, DetailsId, Description, Odds , IsWinning1, 1, Description1, 1.25, false2, 1, Description2, 2.50, trueIn the first table tbl_Details is Winnings = "Lost", because is in the second table tbl_DetailsEvents is "false" and "true".If is in the column IsWinning ="true", is in the first table tbl_Details of the column Winning = "Win" .I think for this situation is the best way to use trigger?I need your help how to do with trigger or?I tried trigger but does not works: HelpALTER TRIGGER dbo.Update_BetSlipEvents ON dbo.tbl_BetSlipEventsAFTER INSERT--, UPDATE, DELETEASUPDATE tbl_BetSlipDetailsSET Winnings = CASE WHEN i.IsWinning = 1 THEN 'Win' WHEN i.IsWinning = 0 THEN 'Lost' ENDFROM tbl_BetSlipDetails dINNER JOIN inserted i on i.BetSlipId = d.Id |
|
|
programer
Posting Yak Master
221 Posts |
Posted - 2011-12-12 : 13:29:54
|
| 1 1 10.1.2011 0:00:00 barcelona dsa dsa das NULL 15 1 10.1.2011 0:00:00 mona das das das NULL 16 1 10.1.2011 0:00:00 21 21 21 NULL NULL 0UPDATE tbl_BetSlipDetailsSET Winnings = CASE WHEN i.IsWinning = 1 THEN 'win' WHEN i.IsWinning = 0 THEN 'lost' ENDFROM tbl_BetSlipEvents dINNER JOIN inserted i on i.BetSlipId = d.IDHow to always to show win if i have in database3x = 1If i have 1x=1 and 2x=0 returns: win.I would like if you in columns IsWinnings=1returns "win". |
 |
|
|
|
|
|
|
|