- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Select
random.verbvocabconnector.id,
random.verbvocabconnector.verbid,
random.verbvocabconnector.vocabid,
random.verbs.id As id1,
random.verbs.verb,
random.vocabulary.id As id2,
random.vocabulary.vocabulary
From
random.verbvocabconnector Inner Join
random.vocabulary
On random.vocabulary.id = random.verbvocabconnector.vocabid Inner Join
random.verbs
On random.verbvocabconnector.verbid = random.verbs.id
Where
random.vocabulary.id = 2
通过使用变量vocabid,我可以列出与词汇表相关的所有动词。但我想做相反的事情,如果 id 为 2,则不显示与该词汇表相关的动词并显示所有其他动词。您可以在图像上看到详细的表结构。提前致谢。
编辑:我得到了这些表:动词、词汇、verbandvocabconnector。
CREATE TABLE `verbs` (
`id` int(11) NOT NULL,
`verb` text NOT NULL,
`regularorirregular` int(11) NOT NULL,
`irregular` text NOT NULL,
`irregular2` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `verbs` (`id`, `verb`, `regularorirregular`, `irregular`, `irregular2`)
VALUES
(1, 'eat', 1, 'ate', 'eaten'),
(2, 'repair', 0, '', ''),
(3, 'clean', 0, '', ''),
(4, 'use', 1, 'used', 'used'),
(8, 'slice', 1, 'sliced', 'sliced'),
(6, 'drink', 1, 'drank', 'drunk'),
(7, 'wash', 0, '', '');
CREATE TABLE `vocabulary` (
`id` int(11) NOT NULL,
`vocabulary` text NOT NULL,
`category` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `vocabulary` (`id`, `vocabulary`, `category`)
VALUES
(1, 'apple', 'fruits'),
(2, 'your car', 'object'),
(3, 'his toothbrush', 'object'),
(4, 'banana', 'fruits'),
(5, 'our dishwasher', 'object'),
(6, 'tea', 'drinks'),
(7, 'soda', 'drinks'),
(8, 'fruit juice', 'drinks');
CREATE TABLE `verbvocabconnector` (
`id` int(11) NOT NULL,
`verbid` int(11) NOT NULL,
`vocabid` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `verbvocabconnector` (`id`, `verbid`, `vocabid`)
VALUES
(1, 1, 1),
(2, 1, 4),
(3, 2, 2),
(4, 2, 5),
(6, 3, 2),
(7, 3, 3),
(8, 3, 5),
(9, 4, 2),
(10, 4, 3),
(11, 4, 5),
(13, 5, 2),
(14, 5, 5),
(15, 6, 6),
(16, 6, 7),
(17, 6, 8),
(18, 7, 2),
(19, 7, 1),
(20, 7, 3),
(21, 8, 1),
(22, 8, 4);
以及我想从这些表中获得的输出;当我选择 id = 2 的词汇表时,它应该列出连接器表中未连接的动词。如果第二个词汇是“你的车”,则不应列出“修理、清洁、使用、清洗”,而必须列出“吃、切片、喝”。
最佳答案
对于这样的问题,我从我要寻找的动词开始。
select * from verbs where ...
您提到您可以构建一个查询,通过连接表来查找与词汇表 2 关联的动词。
select verbid from verbvocabconnector
where verbvocabconnector.VOCABID = 2
将这两者结合起来,您需要此查询未返回的动词。只要您只返回动词 id,您就可以选择具有 id 的动词,或者在本例中,不在该子查询选择中选择动词
select * from verbs
where id not in (subquery);
关于mysql - 与复杂的查询相反?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36584888/
这个问题不太可能帮助任何 future 的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visit
我想从输入对象内部开始找到下一个表单元素。Find() 是查找子对象的绝佳函数。但是在父级中寻找相反的方法呢?
是否可以执行$(this)的相反操作? 因此,它不是获取 this 元素,而是获取与 .sb-popular-thumb a 匹配但不包括 $(this) 的所有内容? 请参阅下面的示例代码。我已用
这是一个关于术语的问题。 考虑到有一个方法使用词法this: var foo = { method: function () { console.log(this, ' is the co
我想问你是否存在一个与 WHERE IN 相反的命令,我想选择数组中具有不同参数的所有行。 1 && id <> 2 && id <> 3"; // how can i do the same q
是否有语法来获取不在给定切片内的列表元素?给定切片 [1:4] 很容易得到这些元素: >>> l = [1,2,3,4,5] >>> l[1:4] [2, 3, 4] 如果我想要列表的其余部分,我可以
这个问题在这里已经有了答案: How can I remove a specific item from an array? (138 个回答) 关闭8年前。 JavaScript push(); 方
在此先感谢您的帮助。这是一个很棒的社区,我在这里找到了许多编程答案。 我有一个包含多个列的表,其中5个包含日期或null。 我想编写一个本质上将5列合并为1列的sql查询,条件是如果5列中的1包含“N
我使用 hasClass() 在 if 语句中验证元素是否具有给定的类。 如果元素没有给定的类,如何检查 if 语句?预先感谢您的回复。 最佳答案 为什么不简单地: if (!el.hasClass(
我有一个 std::vector v我想防止进一步写入它。 C++ 编译器不接受这个 const std::vector& w = v; 但它接受这个 const std::vector& w = r
这个问题已经有答案了: How to reshape data from long to wide format (14 个回答) 已关闭 7 年前。 我有像这样的巨大数据框: SN = c(1:10
如何将可调用(匿名函数)转换为字符串进行评估? 我正在尝试在 phpunit 中编写使用 runkit 的单元测试覆盖方法。特别是,runkit_method_redefine() 需要一个字符串参数
我想实现一个堆栈(队列),许多用户可以以 FILO 方式将其推送(),并且许多用户可以从中弹出()。 是否有与 pop() 等效的方法来检索/删除列表的最后一项? 例如: var popRef = f
我想知道“无状态协议(protocol)”的反面是什么。例如,鉴于 HTTP 是无状态的,那么像 FTP 这样的协议(protocol)是相反的/维护状态的协议(protocol),我的假设是否正确?
我对array_filter很熟悉,想往功能上想,但我想知道有没有办法保留被丢弃的值?例如,如果我有一个像这样的数组: 2; }); 结果将是:array( 3, 4 )。 有没有办法保留丢弃的值
我已将色轮的图像加载到 Canvas 上,并且在数组中有一个色相值列表。我遍历 Canvas 上的每个像素,并删除匹配相同色相值的像素。 该代码是: var element = document.ge
这个问题在这里已经有了答案: Repeat each row of data.frame the number of times specified in a column (10 个答案) 关闭
如何将可调用(匿名函数)转换为字符串以进行评估? 我正在尝试在使用 runkit 的 phpunit 中编写单元测试覆盖方法。特别是,runkit_method_redefine() 需要一个字符串参
我对array_filter很熟悉,想往功能上想,但我想知道有没有办法保留被丢弃的值?例如,如果我有一个像这样的数组: 2; }); 结果将是:array( 3, 4 )。 有没有办法保留丢弃的值
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
我是一名优秀的程序员,十分优秀!