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 |
|
mohdasim87
Starting Member
3 Posts |
Posted - 2009-07-10 : 18:47:54
|
| Frnds, i am new to SQL , i am trying to use SQL update command with where as a clausei want to update 2 specific roll numbers. Currently i am doing thisupdate dbnameset program = 'MS'where rno = '001' This works perfectly , but when i try to update both of them at the same time it dosnet like update dbnameset program = 'MS'where rno = '001' and rno = '002'this command executes perfectly , but shows 0 effected rows. ANYONE can help me out. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-10 : 19:41:42
|
[code]update dbnameset program = 'MS'where rno = '001' and OR rno = '002'[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
mohdasim87
Starting Member
3 Posts |
Posted - 2009-07-11 : 04:33:28
|
| Friend , when i type your syntax it gives me this error :-Msg 156, Level 15, State 1, Line 3Incorrect syntax near the keyword 'OR'.and when i remove OR from there it give me this :-(0 row(s) affected)but when i try to update just 1 roll number , then it gives me this msg(1 row(s) affected) |
 |
|
|
mohdasim87
Starting Member
3 Posts |
Posted - 2009-07-11 : 04:34:38
|
| Thanks , it worked with OR |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-07-11 : 04:34:55
|
| That should beupdate dbnameset program = 'MS'where rno = '001' OR rno = '002'orupdate dbnameset program = 'MS'where rno in ('001' , '002')MadhivananFailing to plan is Planning to fail |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-11 : 04:40:15
|
quote: Originally posted by mohdasim87 Friend , when i type your syntax it gives me this error :-Msg 156, Level 15, State 1, Line 3Incorrect syntax near the keyword 'OR'.and when i remove OR from there it give me this :-(0 row(s) affected)but when i try to update just 1 roll number , then it gives me this msg(1 row(s) affected)
you must have just COPY AND PASTE. Note that I strike off the and keyword. KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-07-11 : 06:18:17
|
quote: Originally posted by khtan
quote: Originally posted by mohdasim87 Friend , when i type your syntax it gives me this error :-Msg 156, Level 15, State 1, Line 3Incorrect syntax near the keyword 'OR'.and when i remove OR from there it give me this :-(0 row(s) affected)but when i try to update just 1 roll number , then it gives me this msg(1 row(s) affected)
you must have just COPY AND PASTE. Note that I strike off the and keyword. KH[spoiler]Time is always against us[/spoiler]
Thats why I dont use strike option in sql MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|