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 |
|
asifbhura
Posting Yak Master
165 Posts |
Posted - 2010-03-30 : 05:06:40
|
| SELECT * FROM Vacation_Process WHERE (chairman_Isaction='Yes' AND Chairman_Approve='1') OR (Isaction_0='Yes' AND IsLevel0_Approve='1') OR (Isaction_1='Yes' AND IsLevel1_Approve='1') OR (Isaction_2='Yes' AND IsLevel2_Approve='1') OR (Isaction_3='Yes' AND IsLevel3_Approve='1') and (isAction_HR='No' AND emp_id is not null)this is my query but it doesnt return correct recordsit shows also Is_Action_HR='Yes'actually i want records where all bracket conditions must be true andemp_id is not null and isAction_HR='No'any other solution would be appriciatedRegards,ASIF |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-03-30 : 05:08:51
|
| SELECT * FROM Vacation_Process WHERE (chairman_Isaction='Yes' AND Chairman_Approve='1')and (isAction_HR='No' AND emp_id is not null)(OR (Isaction_0='Yes' AND IsLevel0_Approve='1')OR (Isaction_1='Yes' AND IsLevel1_Approve='1')OR (Isaction_2='Yes' AND IsLevel2_Approve='1')OR (Isaction_3='Yes' AND IsLevel3_Approve='1'))MadhivananFailing to plan is Planning to fail |
 |
|
|
Buzzard724
Yak Posting Veteran
66 Posts |
Posted - 2010-03-30 : 05:10:12
|
| (chairman_Isaction='Yes' AND Chairman_Approve='1'AND isAction_HR='No' AND emp_id is not null)AND((Isaction_0='Yes' AND IsLevel0_Approve='1')OR (Isaction_1='Yes' AND IsLevel1_Approve='1')OR (Isaction_2='Yes' AND IsLevel2_Approve='1')OR (Isaction_3='Yes' AND IsLevel3_Approve='1')) |
 |
|
|
asifbhura
Posting Yak Master
165 Posts |
Posted - 2010-03-30 : 05:15:18
|
| not working both of them |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-03-30 : 05:17:16
|
| Post some sample data with expected resultMadhivananFailing to plan is Planning to fail |
 |
|
|
asifbhura
Posting Yak Master
165 Posts |
Posted - 2010-03-30 : 05:26:40
|
| I have one one records of all condition i run your query it gives error likeMsg 156, Level 15, State 1, Line 32Incorrect syntax near the keyword 'OR'. |
 |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-03-30 : 05:43:43
|
| A small correction in madhivanam's query.I feel its typo error.SELECT * FROM Vacation_Process WHERE (chairman_Isaction='Yes' AND Chairman_Approve='1')and (isAction_HR='No' AND emp_id is not null)AND((Isaction_0='Yes' AND IsLevel0_Approve='1')OR (Isaction_1='Yes' AND IsLevel1_Approve='1')OR (Isaction_2='Yes' AND IsLevel2_Approve='1')OR (Isaction_3='Yes' AND IsLevel3_Approve='1'))Regards,BohraI am here to learn from Masters and help new bees in learning. |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-03-30 : 05:50:07
|
The WHERE clause is mising a predicate.SELECT *FROM Vacation_ProcessWHERE (chairman_Isaction='Yes' AND Chairman_Approve='1') and (isAction_HR='No' AND emp_id is not null) <INSERT LOGIC HERE> ( OR (Isaction_0='Yes' AND IsLevel0_Approve='1') OR (Isaction_1='Yes' AND IsLevel1_Approve='1') OR (Isaction_2='Yes' AND IsLevel2_Approve='1') OR (Isaction_3='Yes' AND IsLevel3_Approve='1') ) Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
|
|
|