Example is used to add conditions, equivalent to the part after WHERE.
SelectByExample solves almost any query.
Here’s an example:
Example example = new Example(); Example.Criteria criteria = example.createCriteria(); criteria.andStatusEqualTo(1); List<User> list = this.skuMapper.selectByExample(example); List.get (0) is the desired objectCopy the code
Select * from selectByExample(example) select * from selectByExample(example);
Method description:
// 1. Add ascending order. DESC is descending order
Example. SetOrderByClause (” ASC”)
// 2. Delete duplicates, Boolean type, true for records that do not repeat
example.setDistinct(false)
// 3. Add the condition that field XXX is null
criteria.andXxxIsNull
// 4. Add the condition that field XXX is not null
criteria.andXxxIsNotNull
// 5. Add the XXX field equal to value condition
criteria.andXxxEqualTo(value)
// 6. Add XXX field does not equal value condition
criteria.andXxxNotEqualTo(value)
// 7. Add the XXX field greater than value condition
criteria.andXxxGreaterThan(value)
// 8. Add the condition that the XXX field is greater than or equal to value
criteria.andXxxGreaterThanOrEqualTo(value)
// 9. Add the condition that the XXX field is less than value
criteria.andXxxLessThan(value)
// 10. Add the condition that the XXX field is less than or equal to value
criteria.andXxxLessThanOrEqualTo(value)
// 11. Add the XXX field value to List
criteria.andXxxIn(List)
// 12. Do not add XXX field values to List
criteria.andXxxNotIn(List)
// 13. Add the XXX field value between
criteria.andXxxBetween(value1,value2)
// 14. Add XXX field values are not between
criteria.andXxxNotBetween(value1,value2)