Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何为单元格数组的内容编写SQL查询?_Sql_Matlab - Fatal编程技术网

如何为单元格数组的内容编写SQL查询?

如何为单元格数组的内容编写SQL查询?,sql,matlab,Sql,Matlab,抱歉,如果这是相当明显的!如果我有一个键值单元格数组,我应该如何最好地查询数据库中的键值 例如,如果我有单元格数组: Names = { 'Jon', 'Peter', 'Paul' }; 我是否必须以以下形式编写SQL: select * from x where name = 'Jon' or name = 'Peter' or name = 'Paul'; select * from x where name = {Names}; 或者有没有某种形式的写作方法: select * f

抱歉,如果这是相当明显的!如果我有一个键值单元格数组,我应该如何最好地查询数据库中的键值

例如,如果我有单元格数组:

Names = { 'Jon', 'Peter', 'Paul' };
我是否必须以以下形式编写SQL:

select *
from x
where name = 'Jon' or name = 'Peter' or name = 'Paul';
select *
from x
where name = {Names};
或者有没有某种形式的写作方法:

select *
from x
where name = 'Jon' or name = 'Peter' or name = 'Paul';
select *
from x
where name = {Names};
虽然我可以编写一个函数来生成where子句,但这感觉远远不够理想


非常感谢您的帮助。

您可以在中使用

SELECT *
FROM   x
WHERE  name IN ('Jon', 'Peter', 'Paul')

我至少可以想出两种方法:

在where子句中,您可以使用: “在(‘乔恩’、‘彼得’)中”

或者,如果在表中有要查询的名称,只需使用 “其中名称位于(从[具有名称的表]中选择名称)”


希望对您有所帮助。

您可以使用单元格数组而不是字符串吗?我想根据数组的内容(不是常量)生成查询,