mysql basic grammar exercises

1. The difference between left join, right join and inner join in sql

  left join (left join) returns all records in the left table and records with equal join fields in the right table 
  right join (right join) returns including the right table All records in the left table with equal join fields

  inner join (equi-join) returns only records with equal join fields in both tables

2. Modify a field in the data in the table

       update table_name set column1 = value1, colunm2 = value2...where ...;

3. Add or modify fields to the table

        ALTER TABLE table_name  ADD/MODIFY  columnName type (int) default value (DEFAULT NULL) description (COMMENT)

Fourth, case when syntax

       

        There are two forms

        1. column is any field that needs to be compared, value is the value to compare, result is the specified result, and name is the column name that returns this column

           CASE column  WHEN value1 THEN result1            WHEN value2 THEN result2 ...             ELSE result3  
           


           END AS NAME 

          2, the two spellings are basically similar

           CASE 
           WHEN   column  = value1 THEN result1 
           WHEN   column  = value2 THEN result2 ...  
           ELSE result3  

           END AS NAME 

           practise

SELECT login_name , 
            CASE login_name
            WHEN 'dawn' THEN 'star'
            WHEN 'lisi' THEN 'ordinary man'
            ELSE 'not a man'
            END AS type

            FROM saut_m_user WHERE id > 0

           result

         

5. Pass in an array parameter in mapper

              <if test="applyStatus != null and applyStatus.size() > 0 ">
and loan.apply_status in
<foreach item="item" index="index" collection="applyStatus"
open="(" separator="," close=")">
#{item, jdbcType=BIGINT}
</foreach>
</if>

         

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325857880&siteId=291194637