数据库
首页 > 数据库> > sql

sql

作者:互联网

sql

1, group_concat 统计分类用逗号隔开.

2, left jion on
[Err] 1054 - Unknown column ‘o.ordersId’ in ‘on clause’

解决方法:将from后面的表用()来。

例:

SELECT a.id, b.id, c.id FROM A a, B b LEFT JOIN C c ON c.a_id = a.a_id AND c.b_id = b.b_id
这句话在mysql5下执行会有问题,要把联合的表用括号包含起来才行:

SELECT a.id, b.id, c.id) FROM (A a, B b) LEFT JOIN C c ON c.a_id = a.a_id AND c.b_id = b.b_id

postgre

jsonb_set(target jsonb, path text[], new_value jsonb[,create_missing boolean])
target : 这是目的json数据,这里使用内部关联将对应的json查询出来
path : json数据对应的key值(如果是字典就使用"key"值,如果是列表就使用index值,依次排列)
new_value : json数据替换的value值
create_missing : true - 如果不存在对应的key值,则新增,反之,false - 不做其他操作,这里可有可无
info {“t”: [{“t”: 14}], “id”: 1, “age”: 14, “name”: “小明”}
SELECT info || ‘{“gender”:“男”}’::jsonb from zhangt1 where (info ->>‘id’)::int4 = 1;
SELECT info ||’{“age”:22}’::jsonb from zhangt1 where (info->>‘id’)::int4 = 1;
update zhangt1 set info=(jsonb_set(info::jsonb, ‘{t,0,t}’,‘14’ ,false));
update queries d set options=(jsonb_set(d.options::jsonb,’{parameters,0,value}’,’"%"’,false))
from dashboards a, widgets b, visualizations c
WHERE a.id=b.dashboard_id
and b.visualization_id=c.id and c.query_id=d.id
and a.slug = ‘-_12’

标签:info,set,jsonb,json,sql,id,SELECT
来源: https://blog.csdn.net/qq_18246731/article/details/109993126