Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/83.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_Sqlite - Fatal编程技术网

Sql 从表中选择多行

Sql 从表中选择多行,sql,sqlite,Sql,Sqlite,我使用此查询从表中选择一行:- select identifier, name from content where rawid= (select contentid from content where rawid='002cd122-f604-4093-b242-1bd12eafaceb') 我需要一个查询,它将从content中选择所有行,这样每一行都对应于另一个表(称为rawIdentifiers)中的rawid。 我想从这个表中给出rawid,rawid标识符:-

我使用此查询从表中选择一行:-

select identifier, name from content where rawid=
        (select contentid from content where rawid='002cd122-f604-4093-b242-1bd12eafaceb')
我需要一个查询,它将从
content
中选择所有行,这样每一行都对应于另一个表(称为rawIdentifiers)中的
rawid
。 我想从这个表中给出rawid,rawid标识符:-

例如,此查询将给我一行:-

select identifier, name from content where rawid=
            (select contentid from content where rawid='00504a25-bc6a-4edd-8c30-cb57e12b7c3d')
这将为其他行提供:

    select identifier, name from content where rawid=
                    (select contentid from content where rawid='002cd122-f604-4093-b242-1bd12eafaceb')
等等


我需要一个查询来获取表中的所有行。我该怎么做呢?

我想您需要一个内部联接来为您进行匹配。由于您没有为
内容
表提供表结构,因此我尝试将示例代码的各个部分组合起来,为您提供一个工作示例:

select identifier, name 
from content 
inner join content ON rawid = (select contentid from content where rawid='00504a25-bc6a-4edd-8c30-cb57e12b7c3d')

这里的想法是从
content
中获取所有记录,但是每个记录都有一个
content
中的另一个记录。连接的完成方式类似于1记录的
where
子句。

听起来像是要进行连接。您可能需要阅读有关联接的内容,以便了解它们到底在做什么。我想你想要的东西大致如下:

select identifier, name 
from content 
inner join rawidentifiers ON content.identifier = rawidentifiers.identifier

我不确定您的确切表结构,所以我在猜测列名。

听起来您需要进行连接。如果两个表都没有DDL,则很难提供语法。你能把DDL寄出去吗?