我正在为我的 Psych 课程创建一个数据库,并且我正在为一个性格档案评分。我需要比较两个测试项目,如果它们符合条件,则复制到单独的表中。
示例(伪代码在\之间)Sqlite3
INSERT INTO Scale
SELECT* FROM Questions
WHERE \\if Question 1 IS 'TRUE' AND Question 3 IS 'FALSE' THEN Copy this Question
and its response into the Scale table\\;
我还有大约 100 个其他类似的问题。示例格式如下:
IF FirstQuestion IS value AND SecondQuestion IS value THEN
Copy both questions into the Scale TABLE.
---------- 第一反应后编辑!编辑如下----------
这是我的 TestItems 表:
ItemID | ItemQuestion | ItemResponse
```````````````````````````````````````````````````
1 | Is the sky blue? | TRUE
2 | Are you a person? | TRUE
3 | 2 Plus 2 Equals Five | FALSE
我想要做什么:如果问题 1 是 TRUE 并且问题 3 是 FALSE,那么将两个问题都插入到表 'Scale' 中(它的设置类似于 TestItems)。我试过这个:
INSERT INTO Scale
SELECT * FROM TestItems
WHERE ((ItemID=1) AND (ItemResponse='TRUE'))
AND ((ItemID=3) AND (ItemResponse='FALSE'));
但是:上面的 INSERT 都不复制。生成的“比例”表应如下所示:
ItemID | ItemQuestion | ItemResponse
```````````````````````````````````````````````````
1 | Is the sky blue? | TRUE
3 | 2 Plus 2 Equals Five | FALSE