Home > database > For help! Urgent ~ ~ query fields blank skip the where condition, when no is empty, concludes that t
For help! Urgent ~ ~ query fields blank skip the where condition, when no is empty, concludes that t
Time:09-25
Such as A table with id, name, age three fields When the id field is empty query condition, the SQL statement for the where name='x' and age='y' When the name field is empty query condition, the SQL statement for the where id='x' and age='y' When the age field input query condition is empty, the SQL statement for the where id='x' and name='y'. How do you write for SQL '
CodePudding user response:
Everyone a great god the great god,
CodePudding user response:
CodePudding user response:
Dynamic splicing SQL,
The original poster can draw lessons from the mybatis,
CodePudding user response:
Select id, age, name the from the TAB where id is null and age='x' and name='y' Union all Select id, age, name the from the TAB where the name is null and id='x' and name='y' Union all Select id, age, name the from the TAB where age is null and id='x' and name='y'