英文:
Obtain names from foreign key relationship
问题
我想要修改我的查询结果,以便给我不同的结果,例如
当我运行这个查询
select *
from receipt
where receiptId = 358914592
它给我一个表格,像这样
receiptId | date | price | salesRep | PatientId | stat | reqDoc | reviewwee | patho | medtech |
---|---|---|---|---|---|---|---|---|---|
358914592 | 2023-06-21 | 1200 | NULL | 1023957457 | done | dr. Dave | 10111012317 | 64242 | 32347 |
我想要查询显示病理医师、审核人员和医疗技师的姓名,而不是它们的主键
像这样
receiptId | date | price | salesRep | PatientId | stat | reqDoc | reviewwee | patho | medtech |
---|---|---|---|---|---|---|---|---|---|
358914592 | 2023-06-21 | 1200 | NULL | 1023957457 | done | dr. Dave | nurse Joy | Dr. Hawk browns | michaela jose |
英文:
I would like to alter my query result to give me a different result for example
when I run this query
select *
from receipt
where receiptId = 358914592`
It gives me a table like this
receiptId | date | price | salesRep | PatientId | stat | reqDoc | reviewwee | patho | medtech |
---|---|---|---|---|---|---|---|---|---|
358914592 | 2023-06-21 | 1200 | NULL | 1023957457 | done | dr. Dave | 10111012317 | 64242 | 32347 |
I want the query to show the names of the pathologist, reviewee and medtech rather than their primary keys
like this
receiptId | date | price | salesRep | PatientId | stat | reqDoc | reviewwee | patho | medtech |
---|---|---|---|---|---|---|---|---|---|
358914592 | 2023-06-21 | 1200 | NULL | 1023957457 | done | dr. Dave | nurse Joy | Dr. Hawk browns | michaela jose |
答案1
得分: -1
需要使用连接操作才能显示该信息。
select receiptId, date, price, patient,..., path.name...
from receipt as rec
join pathologist as path on rec.pathId = path.Ud
where receiptId = 358914592
英文:
You need to use Joins in order to display that information.
select receiptId, date, price, patient,..., path.name...
from receipt as rec
join pathologist as path on rec.pathId = path.Ud
where receiptId = 358914592`
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论