douya2006 2011-07-27 13:25
浏览 36
已采纳

MySQL从不同的表中检索2个值

I didn't know how to explain it in so few words as to fit it in the title. However it's not really complicated. I have 2 tables, the first called "Lines" has these 2 columns:

Text  PID

and the second called Poems these 2:

PID Title

I need to SELECT rows from the first table when they are equal to $something and then look up on the table Poems for the matching row (the one that has the same PID) and display both the Text from the first table and the Title from the second.

How can this be done? Thanks

  • 写回答

3条回答 默认 最新

  • dongmeng1868 2011-07-27 13:28
    关注
    SELECT Lines.*, Poems.* FROM Lines 
    INNER JOIN Poems ON(Poems.PID = Lines.PID)
    WHERE Lines.Text = 'SOME VALUE'
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Matlab问题解答有两个问题
  • ¥50 Oracle Kubernetes服务器集群主节点无法访问,工作节点可以访问
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架
  • ¥15 有关sql server business intellige安装,包括SSDT、SSMS。
  • ¥15 stm32的can接口不能收发数据
  • ¥15 目标检测算法移植到arm开发板
  • ¥15 利用JD51设计温度报警系统
  • ¥15 快手联盟怎么快速的跑出建立模型