我对sql很新,所以请耐心等待。我有两个名为vascuproimagefile
和datamig1.imagefile
的表。我想将vascuproimagefile.imagefile
与vascuproimagefile.thumbnail
和<>
进行比较,并返回select * from datamig1, vascuproimagefile where datamig1.ImageFile = vascuproimagefile.ImageFile;
彼此的结果。我能够运行这个查询,他们=彼此在哪里,它完美的工作原因为什么它不能用于&lt;&gt;
<!DOCTYPE html>
<html>
<head>
<style>
</style>
</head>
<body>
<div class="onlyOne" data-need="hey there"></div>
<script type="text/javascript">
var myVar = document.getElementsByClassName("onlyOne")[0].getAttribute("data-need");
alert(myVar);
</script>
</body>
</html>
答案 0 :(得分:2)
有几种不同的方法可以做到这一点。一种是使用outer join / null
支票:
select d.imagefile
from datamig1 d
left join vascuproimagefile v on d.imagefile in (v.ImageFile, v.thumbnail)
where v.imagefile is null and v.thumbnail is null
或者您可以使用not exists
:
select imagefile
from datamig1 d
where not exists (
select 1
from vascuproimagefile v
where d.imagefile = v.imagefile or d.imagefile = v.thumbnail
)