sql语句多字段查询语句
⑴ sql语句查询同时满足两个字段
sql
=
"select
*
from
E:\XXX森林资源管理信息系统\mapDataM\小班.dbf
"
+"where
(施业区=
"+frmcaifa.Combo1.List(frmcaifa.Combo1.ListIndex)+")
and
(权属
=
"+frmcaifa.Combo2.List(frmcaifa.Combo1.ListIndex)+")"
施业区
权属
这两个数据库的字段最好取英文名
如果这两个字段的类型为字符串类型
则为
sql
=
"select
*
from
E:\XXX森林资源管理信息系统\mapDataM\小班.dbf
"
+"where
(施业区=
‘"+frmcaifa.Combo1.List(frmcaifa.Combo1.ListIndex)+"’)
and
(权属
=
‘"+frmcaifa.Combo2.List(frmcaifa.Combo1.ListIndex)+"’)"
⑵ SQL多表查询多个字段
SQL语句格式:
select 字段1,字段2,字段3
from 表1,表2,表3
where 条件
例子:查询s表中的sno字段, c表中的cno字段,j表中的jno字段
select sno,pno,jno
from s,p,j
(2)sql语句多字段查询语句扩展阅读:
删除语句:DELETE * FROM table_name
查询语句:SELECT * FROM Persons WHERE ROWNUM <= 5
建立视图:CREATE VIEW view_name AS SELECT column_name(s) FROM table_name WHERE condition
⑶ SQL查询多个字段语句
String ser = request.getParameter("ser");
if(ser != null && ser.length() > 0){
ser="and serialno like '"+ser+"%' ";
}
String id = request.getParameter("id");
if(id != null && id.length() > 0){
id="and id like '"+id+"%' ";
}
String t1 = request.getParameter("t1");
if(t1 != null && t1.length() > 0){
t1="and dt > to_date('"+t1+"','yyyy-mm-dd hh24:mi:ss') ";
}
String t2 = request.getParameter("t2");
if(t2 != null && t2.length() > 0){
t2="and dt < to_date('"+t2+"','yyyy-mm-dd hh24:mi:ss') ";
}
String xw = request.getParameter("xw");
if(xw != null && xw.length() > 0){
xw="and type='"+xw+"'";
}
String sql="select * from lz.user_old where 1=1 "+ser+id+t1+t2+xw;
System.out.println(sql);
ResultSet rt=st.executeQuery(sql);
这个是类似的一段代码,你可以参照改写即可,通过第三方语言处理而组装sql语句即可实现你所要的结果。
⑷ SQL语句中怎样同时查询一个表中的两个字段
select 字段1,字段2,...字段n from 表名(如果有条件的话)where age=12 and name=“小名”(如果想排序的话) order by desc(asc)(如果想限制查询条数的话)limit=10
希望对你有帮助!
⑸ 求 SQL 多表多字段查询语句
Select * from (
Select NAME,PHONE,SPELL from A
unino
Select NAME,PHONE,SPELL from B
union
Select NAME,PHONE,SPELL from C
) as a where a.NAME='张'
⑹ 求一SQL 语句 多表多字段查询
select
a.姓名,a.学号,b.电话
from
表A
a
,表B
b
where
a.姓名
=
b.姓名
给个小议建,姓名有重,学号不重
⑺ 多表中多字段模糊查询 SQL 语句写法
select
distinct
t.编号
from
((select
编号,公司,单号,
订单号
,日期,null
as
物品名称,null
as
规格,null
as
数量,null
as
单价
from
a)union
all(select
表头
,null,null,null,null,物品名称,规格,数量,单价
from
b))t
where
t.公司
like
'%变量%'
⑻ SQL中多条件同时查询语句怎么写
select
*
from
table
where
(品牌=‘条件'
条件
is
null)and
(风格=‘条件'
or
条件
is
null)
在筛选的时候条件也可以是模糊查询
like
'%条件%'
形式的
比如
select
*
from
table
where
品牌
like
'%'||传入的条件||'%'
⑼ SQL语句where多条件查询怎么写
工具/材料:以Management Studio为例。
1、首先在桌面上,点击“Management Studio”图标。
⑽ 需要一个SQL查询语句多表多字段查询
select distinct top 1 husband,a.age as lg年龄,a.money as lg月薪,
wife,b.age as lp年龄,b.money as lp月薪,
a.age+b.age as 合计年龄,a.money+b.money 合计工资
from
FamilyInfo,Detail as a,Detail as b
where a.name='王某' and b.name='赵某'
----------------------
USE [test_123]
GO
/****** 对象: Table [dbo].[Detail] 脚本日期: 09/16/2010 19:07:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Detail](
[ID] [int] NOT NULL,
[name] [nchar](10) COLLATE Chinese_PRC_CI_AS NOT NULL,
[age] [int] NOT NULL,
[money] [int] NOT NULL
) ON [PRIMARY]
-------------------------------
USE [test_123]
GO
/****** 对象: Table [dbo].[FamilyInfo] 脚本日期: 09/16/2010 19:07:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[FamilyInfo](
[ID] [int] NOT NULL,
[husband] [nchar](10) COLLATE Chinese_PRC_CI_AS NOT NULL,
[wife] [nchar](10) COLLATE Chinese_PRC_CI_AS NOT NULL
) ON [PRIMARY]