I have a table of students in which I have few columns like ID,Name,Class,Subject,Marks Now in my table I have these records
| ID | Name | Class | Subject | Marks |
| 1 | ASAD | 5th | ENG | 190 |
| 2 | USMAN | 6th | MATH | 200 |
| 3 | ALI | 4th | ENG | 100 |
| 4 | ABC | 4th | MTH | 78 |
| 5 | BYH | 3rd | ENG | 98 |
| 6 | BHJ | 2nd | ENG | 89 |
| 7 | new | 5th | MATH | 76 |
I like to apply IF conditions and show only those records who are having class 5th and 4th and if class is not equal to 5th or 4th then I wanted to show a message.
the issue is explained below
if(st.class!="5th")
{
Print My Message
}
if(st.class!="4th")
{
print my message
}
This issue is that even if my student is having class "4th" then it still shows the message because it execute the first if condition and it shows the message,it should not show as my second if has class 4th which .
THE ISSUE IS like IF A STUDENT IS HAVING CLASS 4th that is allowed class but the first IF already run and it shows the message how to combine these two if in one if I make the statement like this
if(st.class!="4th" || st.class!="5th") (THEN FROM IT AS IT IS OR OPERATOR IF ONE CONDITION IS TRUE IT WILL BE TRUE , the student must have either 4th or 5th class not both
{
}
Jignesh KumarPosted Apr 3, 2023, 6:40 PM
Hello Mark,
You can check or and not both like below,
Mark TaborPosted Apr 4, 2023, 6:45 PM
Jignesh Kumar it works
Mark TaborPosted Apr 4, 2023, 4:58 AM
Thanks Kumar the thing is one student can have one class I like to show error message if the class is not either 4th or fifth The condition is OR and when I apply OR then if one is true then it become true and show the message it should show only when both are false