SELECT
product_id,
product_name,
category_id,
root_category_id,
sold_num,
product_status,
content,
create_time,
update_time
FROM product
WHERE category_id=#{cid}
limit #{start},#{limit}
SELECT
product_id,
product_name,
category_id,
root_category_id,
sold_num,
product_status,
content,
create_time,
update_time
FROM product
WHERE product_name like #{kw}
limit #{start},#{limit}
联合查询,联合这两个查询组合成sql动态查询
SELECT
product_id,
product_name,
category_id,
root_category_id,
sold_num,
product_status,
content,
create_time,
update_time
FROM product
WHERE product_name LIKE '%example%' -- Replace 'example' with your desired search keyword
LIMIT 10 -- Replace 10 with your desired starting position
OFFSET 0 -- Replace 0 with your desired number of rows to retrieve
UNION
SELECT
product_id,
product_name,
category_id,
root_category_id,
sold_num,
product_status,
content,
create_time,
update_time
FROM product
WHERE category_id = 'example_category_id' -- Replace 'example_category_id' with the desired category ID
LIMIT 10 -- Replace 10 with your desired starting position
OFFSET 0 -- Replace 0 with your desired number of rows to retrieve