两张字段相同表,求SQL语句,谢谢大家
有两张字段相同的表A,B。字段为SN, Name, Operator, Result, Remark
A表中字段SN唯一,B表中字段SN不唯一,有很多条
如何用一条select语句
把符合SN=’abc’的记录从A,B表中筛选出来?
SQL code:
SELECT *
from A
INNER JOIN B ON A.SN=B.SN AND A.SN='abc'
SQL code:
select * from a where SN='abc'
union all
select * from b where SN='abc'
select * from a where SN='abc'
union all
select * from b where SN='abc'
你们好快。。
谢谢大家,解决的太快了,看来我的问题太简单了。。。。。 汗
但是还是谢谢大家:)
js_szy 和SN唯一没关系,呵呵 只是发问的时候想把问题描述清楚 谢谢你的解答啊
相关问答:
哪位高手提供一个SQl语句,控制表中指定列的值必须是正数?
在程序里面判断不好吗??
你可以在建表的时候用check约束表中的该字段呀!
如:
create table tab_name(
name varchar2(20),
age numbe ......
数据库某表,想将其中f1,f2两个字段的内容翻10倍,请教如何写法?
update tbl set f1= f1*10,f2= f2*10 where id=10451
这种写法会造成plsql卡死
不会吧,那个id=10451 的数据有多少啊~~~~
我估计sql是不 ......
比如 有一字段为:
Num
6111
6201
6520
65121
60087
46300
我想把6开头的全都替换成5开头
注意这是表里的数据,我想用SQL语句实现替换
SQL code:
update tb set
num = s ......
现在有表A(barcode varchar2,length number),B(barcode varchar2,serial number)其中barcode关联A:B为1:n
有如下sql语句
insert into a values('b1',10)
insert into a values( ......
数据类型:
Code char(6)
CreateTime datetime
Price float
数据如下:
Code CreateTime Price
031021 2008-10-17 15:00:1 ......