Transpose SQL code into MATLAB

조회 수: 1 (최근 30일)
Cristian Martin
Cristian Martin 2022년 6월 15일
Hi,
I have an SQL query that is ok in Workbench, the results are I expected:
SELECT * FROM prices.prices WHERE (Var5 <= 125 and Var5 >= 124 OR Var6 <= 125 and Var6 >= 124 OR Var7 <= 125 and Var7 >= 124) AND (Var8 <= 6 and Var8 >= 5 OR Product <= 6 and Product >= 5 OR Var10 <= 6 and Var10 >= 5);
In Matlab I want to do a query in data base, based on 4 variables 2 min and 2 max values that search in 6 different columns . For only 2 variables min and max value work perfectly but if I add the other two variables to extend the selection in other three columns it failed to show wanted results.
This is the half working:
sqlquery = ['SELECT * FROM prices.prices WHERE Var5 <= ',caseta2 ' and Var5 >= ',caseta1 ' OR Var6 <= ',caseta2 ' and Var6 >= ',caseta1 ' OR Var7 <= ',caseta2 ' and Var7 >= ',caseta1];
And full code:
sqlquery = ['SELECT * FROM prices.prices WHERE Var5 <= ',caseta2 ' and Var5 >= ',caseta1 ' OR Var6 <= ',caseta2 ' and Var6 >= ',caseta1 ' OR Var7 <= ',caseta2 ' and Var7 >= ',caseta1 ' AND Var8 <= ',caseta4 ' and Var8 >= ',caseta3 ' OR Product <= ',caseta4 ' and Product >= ',caseta3 ' OR Var10 <= ',caseta4 ' and Var10 >= ',caseta3 ];
selectie = fetch(conn,sqlquery);
In the Workbench I could used paranthesis and "AND" between criteria but in Matlab I don't know how to use it

답변 (0개)

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

제품


릴리스

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by