mybatis中的查詢

2021-09-24 02:30:08 字數 1022 閱讀 3861

第一種,根據建立時間查詢,搜尋框中開始時間和結束時間,在搜尋的時間段中包含建立時間的記錄被查詢出來

and  a.insert_date

between #

and #

第二種,模糊查詢,根據關鍵字模糊查詢

and  a.car_id like '%$%'

第三種,統計,如果統計結果只有一條並且只有一列,那麼直接返回integer型別即可

int getcount(mapparammap);

select

count(id)

from

`tb_admin`

where role_id in(select role_id from tb_role)

where role_id in(

select role_id from tb_role where 

province = # 

and city is not null

and city = #

and    `partition` is not null

and    `partition` = #)

如果有多行並且有多列,那麼,使用實體類對返回結果進行包裝

實體類中

@transient

private string total;

@tablefield("order_status")

private string orderstatus;

select

count(order_no) as total,

order_status

from

tb_tax_order

where

station_staff_id = #

and date_sub(curdate(), interval 1 month) date(insert_date)

group by order_status

Mybatis中的模糊查詢

1.當我們從資料庫中查詢資料時,大批量的資料會存在相同的資料。比如重名的人,當我們使用姓名查詢該姓名的所有資料時,我們需要在mybatis中使用到模糊查詢的概念。在介面中定義函式 模糊查詢 使用name查詢的資料為物件tb7,返回的不止乙個物件使用list public listquerybynam...

MyBatis中的模糊查詢

在dml中 模糊查詢用 like 實現 那麼在mybatis中怎麼去實現呢?一頓操作猛如虎 敲出以下 1 select id test 2select3 4from 5test 6where 7test name like 8select 直接 error 1064 缺少單引號 其實很簡單 只需要用...

MyBatis中的多表查詢(3)

目前使用的查詢方式遇到的問題 可以使用多表查詢的sql語句解決 執行的sql語句 select from stu s join clazz c on s.clazzzno c.clazzzno多表查詢的sql語句雖然可以查詢出內容,但是沒有乙個合適的實體去接受我們查詢出的內容。a 新建乙個實體類,把...