且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用动态WHERE语句创建SQL查询

更新时间:2023-02-15 09:33:21

您可以使用表之间的联接来解决

You can solve using a join between the tables

SELECT t.*
FROM test_data  t
INNER JOIN criteria c ON t.step =  c.step 
  AND t.temperature > c.temperature_upper 
      AND t.temperature < c.temperature_lower

或如果您想> =和< =

OR if you want >= and <=

SELECT t.*
FROM test_data  t
INNER JOIN criteria c ON t.step =  c.step 
  AND t.temperature netween c.temperature_upper AND  c.temperature_lower