## Select元素标签输入方式
- 基本数据类型
- 字符串类型
- Map 类型
- Java bean 类型
## 案例实操
### 输入参数分类
基本类型,字符串,java bean,map,数组(删除操作时体现),List(添加时体现)等每种情况定义如下
#### 基本数据类型
**Statement 定义**
~~~ xml
<!-- 查询客户-->
<select id="queryCustomerById" parameterType="int" resultType="com.xxx.pojo.Customer">
SELECT id,user_name 'userName',user_balance 'userBalance' FROM yg_customer WHERE id=#{id}
</select>
~~~
**CustomerDao方法定义**
~~~ java
Customer queryCustomerById(int id);
~~~
#### 字符串类型
**Statement 定义**
~~~ xml
<!-- 查询客户-->
<select id="queryCustomerByName" parameterType="string" resultType="com.xxx.pojo.Customer">
SELECT id,user_name 'userName',user_balance 'userBalance' FROM yg_customer WHERE user_name=#{userName}
</select>
~~~
**Dao 方法定义**
~~~ java
Customer queryCustomerById(int id);
~~~
#### Map 类型
**Statement 定义**
~~~ xml
<!-- 输入参数为 map 类型 -->
<!-- 查询客户-->
<select id="queryCustomerByName" parameterType="map" resultType="com.xxx.pojo.Customer">
SELECT id,user_name 'userName',user_balance 'userBalance' FROM yg_customer WHERE user_name=#{userName}
</select>
~~~
**Dao 方法定义**
~~~ java
Customer queryCustomerByName(Map<String,Object> userName);
~~~
#### Java bean 类型
**Statement 定义**
~~~ xml
<!-- 输入参数为 java bean 类型 -->
<select id="queryCustomerByParams" parameterType="customer" resultType="customer">
SELECT id,user_name 'userName',user_balance 'userBalance' FROM yg_customer WHERE user_name=#{userName}
</select>
~~~
**Dao方法定义**
~~~ java
Customer queryCustomerByParams(Customer customer);
~~~
####
## 扩展
### 结果类型分类
基本数据类型,字符串,JavaBean,Map,List等
#### 基本数据类型
**Statement定义**
~~~ xml
<!-- 结果类型为基本数据 -->
<select id="queryCustomerAccount" resultType="int">
select count(1) from yg_customer
</select>
~~~
**Dao 方法定义与对应实现**
~~~ java
int queryCustomerAccount();
~~~
#### 字符串类型
**Statement定义**
~~~ xml
<!-- 结果类型为字符串 -->
<select id="queryCustomerNameById" resultType="string" parameterType="int">
select user_name from yg_customer WHERE id=#{id}
</select>
~~~
**Dao 方法定义**
~~~ java
String queryCustomerNameById(int id);
~~~需要视频配套资料或其他资料+我们小姐姐V lezijie007(加好友暗号 98 ,不备注不加)
#### Java Bean
**Statement定义**
~~~ xml
<select id="queryUserByUser" parameterType="user" resultType="user">
select id,user_name as userName,user_pwd as userPwd from user where id=#{id}
</select>
~~~
#### List
**Statement 定义**
~~~ xml
<resultMap type="user" id="user_map">
<result column="id" property="id"/>
<result column="user_name" property="userName"/>
<result column="user_pwd" property="userPwd"/>
</resultMap>
<sql id="user_column">
id,user_name,user_pwd
</sql>
<select id="queryUserNyName2" parameterType="string" resultMap="user_map">
select <include refid="user_column"/>
from user where user_name like concat("%",#{userName},"%")
</select>
~~~
#### Map 类型数据
**Statement 定义**
~~~ xml
<!-- 结果类型为map -->
<select id="queryUserByIdReturnMap" parameterType="int" resultType="map">
select id,user_name as userName,user_pwd as userPwd from user where id=#{id}
</select>
~~~
###