In specific applications, we often use numeric values to identify various states, such as 0 indicating male, 1 indicating female, or Boolean indicating a logical yes or no State, to make the end user visually see the results, it is clear that it is a good habit to make a simple judgment and processing of the Field Values in the database. You can perform the following operations in access, sqlserver, and Oracle:
In access, select IIF ([field] = 0, 'male', IIF ([field] = 1, 'femal') as Alias from table, in addition, we can add more processing capabilities,
SQL Server uses the select case when field = 0 then 'male' else 'female' end as Alias from table
In Oracle and sqlserver, the syntax is similar to the select case when field = 0 then 'male' else 'female' end as Alias from table. In multiple cases, multiple when then statements can be used for processing.
Under the guidance of the above processing ideas, we can also use more extensive processing methods, such as join table queries and taking access as an example. For example, if data is selected from another table when a certain condition is met, when other conditions are met, use another table ..... for example:
Select IIF ([Status] = 0, (select field from othertable where id = 1), IIF ([Status] = 1, 'femal') as Alias from table
in this way, some application logic can be processed in the database, saving the complexity of Program processing, such as integration. when the net gridview control displays data, it is unnecessary to implement the corresponding conversion logic.