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)
假设题主的数据库是产品数据库
以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%'
以上三种就是单个查找关键字的方法
望采纳
用模糊查询
select * from table where name like ‘A%'
以A结尾:select * from table where name like ‘%A'
包含A:select * from table where name like ‘%A%'
select * from table_name where name like '''A%'