Sql 各种查询

来源:互联网 发布:如何注册淘宝达人 编辑:程序博客网 时间:2024/06/03 18:04
select t.cust_name,t.phone_no from app_cust_info t //通张表查其中的字段select aa.cust_name,aa.phone_no,bb.loan_no from app_cust_info aaleft join app_loan_acct bb on aa.cust_no = bb.cust_noselect t.phone_no from app_cust_info t select t.cust_no from app_cust_info twhere phone_no='18607355063'//通张表通过电话查询对应的select * from app_cust_info //查询所有select ala.loan_no from app_cust_info alcleft join app_loan_acct ala on alc.cust_no=ala.cust_nowhere phone_no='18636937160'//关联查询

 


select *  from pub_branch_group_settle t               select t.group_no          from pub_branch_group_settle t         where commission_type = '80000007'        <!-- 创建一张表-->         create table table_test1(id varchar2(40) primary key,                           goods_one varchar2(40),                           goods_two varchar2(40),                           goods_three varchar2(40)                                                      )        <!--插入一张表-->         insert into table_test1                  select sys_guid(), '001', '00101', 'a'                  from dual                union all                select sys_guid(), '001', '00101', 'b'                  from dual                union all                select sys_guid(), '001', '00202', 'aa'                  from dual                union all                select sys_guid(), '001', '00202', 'bb'                  from dual                       <!--查询-->                        select *                          from table_test1                               <!--关联查询 根据一级找二级-->                                select goods_one, goods_two                                  from table_test1                                 where goods_one = '001'                                 group by goods_one,                                          goods_two                                          
        <!--关联查询 根据二级找三级-->
select goods_one, goods_two, goods_three from table_test1 where goods_one = '001' and goods_two = '00202'



原创粉丝点击