table2是table1的一部分 [英] table2 is apart of table1

查看:122
本文介绍了table2是table1的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好evry身体
这是我在codeproject中的第一个问题

我有2个表(table1,table2)

table2是table1的一部分

我想显示table1中不在table2中的数据

对不起,我的英语

hello evry body
this my first question in codeproject

i have 2 tables ( table1 , table2 )

table2 is part of table1

i want to show data from table1 where are not in table2

sorry for my English

推荐答案

如果您有

If you have

Table1
 id
 name





and

Table2
 id
 name



那你就可以做



Then you can do

SELECT Table1.* FROM Table1
LEFT JOIN Table2 
   ON Table1.ID = Table2.ID and Table1.Name = Table2.Name
WHERE Table2.ID is NULL



本质上,您是在说尝试基于相似的行连接表1和表2,并仅从表1返回表2中不存在的那些行".



Essentially you''re saying "Try to Join table 1 and Table 2 based on similar rows, and only return those rows from Table1 that don''t exist in Table2"


它"一个简单的任务.看一下这篇文章,以了解有关JOIN s
的所有内容 SQL联接的可视表示 [
It''s a simple task. Take a look at this article to learn everything about JOINs
Visual Representation of SQL Joins[^]
BTW it has the answer


您要过滤数据.这样做的显而易见的方法是只更改填充table2的SQL,以仅将所需的数据放入其中.否则,将数据复制到新源并进行过滤.

欢迎来到Code Project.
You want to filter your data. The obvious way to do that is to just change the SQL that fills table2, to only put the data you want in there. Otherwise, copy the data to a new source and filter it.

And welcome to Code Project.


这篇关于table2是table1的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆