SELECT WHERE Query with AND OR & NOT combinationsWe will try to add AND and OR combination to our SQL SELECT query here. We can get our required requirement by using AND combination. This way we can restrict our records.You can also read how AND and OR is used in SQL script for MySQL tables Let us say we are interested in getting records of class Five only. Here is the query. rs1.open " SELECT * FROM student WHERE class='Five' " , connNow we will collect records of the student of class five who has secured more than 80 marks.rs1.open " SELECT * FROM student WHERE class='Five' AND mark > 80 " , connNow let us try to collect all the records who have secured more than 80 marks. But we will add one more condition . Along with all these records we also want the records of class Four. Here is the queryrs1.open " SELECT * FROM student WHERE class='Four' OR mark > 80 " , connNote how we have added two conditions with one OR.Now let us add one NOT combination to get all the student records who has secured more than 80 mark but we don't want student of class Four. rs1.open " SELECT * FROM student WHERE NOT(class='Four') AND mark > 80 " , connYou can read the record display and download the structure and csv file for student table here
This article is written by plus2net.com team.
Be the first to post comment on this article : ![]() |