SQL中怎么查询名称以‘A

如题所述

1、创建测试表,如下图。

create table test_col_1(id number, var varchar2(200));

create table test_col_2(id number, var varchar2(200));

2、插入测试数据,如下图。

insert into test_col_1 

select level*8, 'var'||level*8 from dual connect by level <= 20;

insert into test_col_2 

select level, 'var'||level from dual connect by level <= 100;

3、查询A表与B表关联记录,如下图。

select *

  from test_col_2 b

 where exists (select 1 from test_col_1 a where b.id = a.id)

4、查询A表全部数据及A、B有关联的数据,如下图。

select *

  from test_col_1 a

union all

select *

  from test_col_2 b

 where exists (select 1 from test_col_1 a where b.id = a.id)

温馨提示:答案为网友推荐,仅供参考
第1个回答  2021-04-17
题主出的题目有些模糊
假设题主的数据库是产品数据库
以A开头:select product_name from Product where product_name like 'A%'
以A结尾:select product_name from Product where product_name like '%A'
包含A:select product_name from Product where product_name like '%A%'
以上三种就是单个查找关键字的方法
望采纳
第2个回答  2012-02-22
以A开头麼

用模糊查询

select * from table where name like ‘A%'
第3个回答  推荐于2017-09-19
以A开头:select * from table where name like ‘A%'

以A结尾:select * from table where name like ‘%A'

包含A:select * from table where name like ‘%A%'本回答被提问者采纳
第4个回答  2012-02-22
以 “ ‘A ” 开头的用
select * from table_name where name like '''A%'