sql - RQDA - 导出项目中每个文件的类别
问题描述
我在 RQDA 中编写了许多文本,我正在尝试将类别导出到数据库中。我希望最终结果是一个像这样的数据框:
Files Categories
File1 Category1
File2 Category2
File3 Category3
File4 Category2
File5 Category1
我尝试了以下从Rblogger改编的代码:
categories <- RQDAQuery("select filecat.name as category, source.name as filename
from treefile, filecat, source
where treefile.catid=filecat.catid and treefile.fid=source.id and treefile.status=1")
但到目前为止它导致了一个空文件:
str(categories)
'data.frame': 0 obs. of 2 variables:
$ category: chr
$ filename: chr
> dim(categories)
[1] 0 2
> summarise(categories)
data frame with 0 columns and 1 row
欢迎任何帮助。
解决方案
旧电子邮件列表中的一些朋友很友善地帮助了我,所以答案如下:
codings <-RQDAQuery("select s.name as 'filename', f.name as 'codes' from source s,
coding c,
freecode f where s.id = c.fid and c.cid = f.id and s.status = 1 order by s.name")
categories <- RQDAQuery("select s.name as 'filename',
co.name as 'categories' from source s,
coding c, freecode f, codecat co,
treecode tr where s.id =
c.fid and c.cid = f.id and co.catid =
tr.catid and tr.cid = f.id and s.status = 1 and c.status = 1 and
f.status = 1 order by s.name")
一切顺利
推荐阅读
- python - 当我尝试在 ul 中获取 li 元素时,我只得到一个 li 而没有别的
- c++ - 在 C++ 中使用逗号运算符时的未定义行为
- java - 当单击每个项目时,回收站视图的每个项目都有不同的数据,显示它在下一个活动中来自数据库的相关数据,使用一个下一个活动
- awk - 使用 AWK 编辑文本文件并制作新的文本文件
- flutter - 未放置导致 RenderBox 的卡片中的 ListTile
- spring - Pivotal 的 Spring Cloud Gateway 指南无法正常工作
- php - MySQL 如何在同一张表上选择多行 WHERE 多列?
- php - Woocommerce 如何替换缺货产品的销售价格但保持正常价格?
- google-chrome - 是否可以在 chrome 开发人员工具中编辑 Extensions WebKit?
- sql - Postgres - 使用 postgis 计算距离