我试图创建一个键/值表,该表将获取老师的姓名和超过80000的薪水。我无法在此处进行SELECT语句。在这里使用Json。
CREATE TABLE instructortest (
ID INT PRIMARY KEY,
info VARCHAR(max) NOT NULL
);
ALTER TABLE instructortest
ADD CONSTRAINT "valid JSON"
CHECK (ISJSON (info) = 1);
INSERT INTO instructortest
VALUES (78699,'{"name":"Pingr","Department":"Statistics","salary":"59303.62"}' )
select JSON_VALUE(info, '$.name') from instructortest
where ('$.salary') = 59303.62
答案 0 :(得分:0)
您只需要在where子句中再次使用JSON_VALUE:
select JSON_VALUE(info, '$.name') from instructortest
where cast(JSON_VALUE(info, '$.salary') as decimal(18,2)) > 80000