Access select where 数据库查询 多表联合查询

Access select where 数据库查询 多表联合查询,第1张

试试 select aid from table1 as a join table2 as b where ( apid = bpid or apid like '%,||bpid or apid like '%,||bpid||,%' or apid like bpid||,%') and bname like '%def%')

select uname 姓名,cname 班级 from user u,class c where uname=‘张三’and uclass=cid

但是建议不同的表如果不是相对应的字段不要取相同的字段名,例如你的user表中的name是用户名,class中的name是班级名,这样容易弄混,望采纳

sql联合查询语句(两张表)是:

select AID,AVALUE,ATYPE,ANAME,BKEY,BID,BVALUE,BNAME 

min(VALUE),max(VALUE) from A left join B on AID = BID

where BNAME="你输入的名字" 

and BVALUE > (select min(VALUE) from B where NAME="你输入的名字")) 

and BVALUE < (select min(VALUE) from B where NAME="你输入的名字"));

延展阅读:

A表字段stuid,stuname。

B表字段bid,stuid,score,coursename,status。

要用一条sql查出A表中所有记录的对应的stuid,max(score),coursename,status,并且status=1,sql语句要求跨数据库,不能使用rownum,top,limit等方言。

比如数据:

A

stuid stuname

11 zhangshan

22 lisi

B

bid sutid coursename scoure status

a 11 yuwen 66 1

b 11 shuxue 78 1

c 11 huaxue 95 0

最后要得到的数据是

stuid couresname scoure status

11 shuxue 78 1

22 null null null

下面这样的SQL语句就可以:

select from db1tb1

union

select from db2tb2

补充:

跨服务器是不可以的,只有逐渐连接每一个服务器获取数据。

我的意见是:1)创建一个webconfig(如果你是web程序),或者是appconfig(如果是WinForm的)。其中在<systemweb>……</systemweb>中加入以下黑色部分文字: <connectionStrings>

<add name="MyConnStr"

connectionString="Data Source=\SQLEXPRESS;

AttachDbFilename=Database1mdf;

Integrated Security=True;

User Instance=True"

providerName="SystemDataSqlClient" />

</connectionStrings>请把数据库和你的程序放到同一个地方(同一个路径)。然后使用SystemConfigurationConfigurationManagerConnetionStrings["MyConnStr"]ConnectionString;读取即可

以上就是关于Access select where 数据库查询 多表联合查询全部的内容,包括:Access select where 数据库查询 多表联合查询、数据库多表联合查询问题,现在我有两个表 表1 user表 id name class 1、sql联合查询语句(两张表)等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/9820041.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-02
下一篇2023-05-02

发表评论

登录后才能评论

评论列表(0条)

    保存