sql

1. select count(*) sku_id from tmall_sku;

 

2. 有的 id 为自增主键:

现在报错是因为这个自增主键冲突了: id
你先把之前的delete了,该插入的SQL应该是这样,你看看有没有问题
INSERT INTO "public"."tmall_aggregate_item" ("create_time", "last_update_time", "color_name", "product_id", "tenant_id", "target_item_id") VALUES
('2022-12-19 09:11:30.598+00', '2022-12-19 09:11:30.598+00', '白色鞋子', 325936669, '69000', 694989508551),
('2022-12-19 06:51:20.107+00', '2022-12-19 06:51:20.107+00', 'lv色', 380835922, '69000', 695554114976),
('2022-12-19 06:51:20.107+00', '2022-12-19 06:51:20.107+00', 'color4', 383248706, '69000', 695554114976),
('2022-12-19 07:40:27.924+00', '2022-12-19 07:40:27.924+00', 'color4', 363456506, '69000', 694985016349),
('2022-12-19 08:03:06.826+00', '2022-12-19 08:03:06.826+00', 'lv色', 319806611, '69000', 694986412638),
('2022-12-19 08:03:06.826+00', '2022-12-19 08:03:06.826+00', '粉色', 365920273, '69000', 694986412638),
('2022-12-19 07:18:25.616+00', '2022-12-19 07:18:25.612+00', 'color3', 387324429, '69000', 695555974394);

 

 

3.

select count (*) from tmall_sku S left join tmall_goods G on S.outer_id=G.item_code
LEFT JOIN:即使右表中没有匹配,也从左表返回所有的行
select count (*) from tmall_sku S join tmall_goods G on S.outer_id=G.item_code/INNER JOIN:如果表中有至少一个匹配,则返回行

RIGHT JOIN:即使左表中没有匹配,也从右表返回所有的行

FULL JOIN:只要其中一个表中存在匹配,则返回行

 

4. 查看首行:
select * from product_attribute LIMIT 1

 

5. 数据库 对values是列表的模糊匹配:

select * from criterion where type='StockPoint' and '9359' = any(values)

 

6. select 前5行数据

select * from tmall_sku order by last_update_time desc limit 5;


7. select 前5行数据
select * from tmall_sku limit 5 offset 1.
忽略第一行数据,从第二行开始 取5行数据

 
posted @ 2023-10-26 11:39  胖妞麻麻  阅读(13)  评论(0)    收藏  举报