我有 2 个表:
CREATE TABLE "book"
(
"id" serial PRIMARY KEY,
"ean_number" TEXT NULL,
"title" TEXT NULL
);
CREATE TABLE "e_book"
(
"id" serial PRIMARY KEY,
"ean" TEXT NULL,
"title" TEXT NULL,
"format" VARCHAR(255) NOT NULL,
"physical_book_ean" TEXT NULL
);
从书到电子书存在一对多或无关系。
我想在我的代码中运行这样的查询:
var q = "select b.*, array_agg(e) ebooks from book b " +
"left join e_book e on e.physical_book_ean = b.ean_number " +
"group by b.id";
using (var cmd = new NpgsqlCommand(q, conn))
using (var reader = cmd.ExecuteReader())
while (reader.Read())
{
//read data
}
array_agg 列电子书作为内容类型出现<unknown>
如何定义内容类型以便我可以阅读它?
BIG阳
相关分类