SQL中如何查詢A表中的資料有部分存在B表中並顯示出來

時間 2021-08-30 15:07:48

1樓:四舍**入

1、select * from b表 where item_no in (select 條碼 from a表)

2、select * from a表,b表 where  a表.條碼=b表.item_no

擴充套件資料:

sql參考語句

刪除表drop table tabname--這是將表連同表中資訊一起刪除但是日誌檔案中會有記錄

刪除資訊

delete from table_name-這是將表中資訊刪除但是會保留這個表

增加列alter table table_name add column_name column_type [default 預設值]--在表中增加一列

2樓:匿名使用者

select * from b表 where item_no in (select 條碼 from a表)

select * from a表,b表 where  a表.條碼=b表.item_no

你看看這兩個哪個符合你要求

3樓:匿名使用者

exists寫法:

select a.條碼

from table1 a

where exists(select 1 from table2 b

where a.條碼 = b.item_no);inner join寫法:

select a.*,b.*

from table1 a

inner join table2 b

on a.條碼 = b.item_no

;還有其他的寫法....小表關聯可以用inselect a.*

from table1 a

where a.條碼 in(select b.item_no from table2 b)

oracle中如何查詢資料表中重複的資料

大話殘劍 可以用分組函式統計,例如在表test中查詢id欄位重複的資料,查詢結果中id是重複的資料值,count 是重複的次數。create table test id number,name varchar2 20 insert into test values 1,a insert into t...

oracle中如何查詢資料表中重複的資料

根據感覺重複的欄位分割槽,加上一個row number,如果row number 1,那麼就找到了重複的資料了 select from select t.owner,t.table name,t.cnt,t.create time row number over partition by t.tab...

SQL中如何在表中新增欄位,在資料表中新增一個欄位的SQL語句怎麼寫

我愛數學 alter table tablename1 add alter column fieldname1 fieldtype nfieldwidth nprecision null not null check lexpression1 error cmessagetext1 default ...