多表搜索 [英] multiple table searching

查看:62
本文介绍了多表搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我想知道在数据库中搜索多个表时的查询吗?我使用了MySQL数据库.

示例我有两个名为table1和table2的表.如果我在表1中搜索某个名称(如果找不到结果),则在另一个表中搜索表2.这可能吗?

表格:table1
Lname(pk)
Fname
表格编号

表格:table2
Lname(pk)
Fname
表格编号

谢谢...

Hi,
I want to know the query in searching multiple tables in db? I used MySQL database.

Example I have two tables named table1 and table2. If I search some name in table1 if results not found then search in the other table table2. Is this possible?

table: table1
Lname (pk)
Fname
TableNo

table: table2
Lname (pk)
Fname
TableNo

thank you...

推荐答案

我建​​议阅读一些有关SQL如何工作的在线文章,这是基本知识.
您使用inner join关键字将两个表连接在一起,您将需要一个在两个表之间共享的值.然后,您可以搜索表之间的数据,但前提是它们之间相互关联.
I suggest reading some online articles about how SQL works, this is basic stuff.

You use the inner join keywords to join two tables together, you will need a value that is shared between the two. Then you can search for data between tables, but only if they are related to one another.


这篇关于多表搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆