繁体   English   中英

从mysql中的多个表中选择多个列

[英]selecting multiple columns from multiple tables in mysql

以下是我的查询

select p.problem_id,
       p.problem_title,
       p.description,
       paps.problem_external_source_id, 
       paps.problem_and_problem_source_id 
  from problem_backup p,
       problem_and_problem_source paps 
 where p.problem_id=paps.problem_id and paps.free_user_id!='null';

我的问题是如何基于检索到的列选择另一个表列(即,在我的查询中,我想根据基于problem_and_problem_source_id从另一个表中选择更多列),我想在同一查询中执行此操作整个程序的工作

您可以以相同的方式加入另一个表。 注意paps.free_user_id!='null'应该是paps.free_user_id is not null ,除非您的意思是user_id实际上是字符串'null'

select p.problem_id,
       p.problem_title,
       p.description,
       paps.problem_external_source_id, 
       paps.problem_and_problem_source_id,
       yat.*
from problem_backup p
inner join problem_and_problem_source paps
  on  p.problem_id = paps.problem_id
inner join your_another_table yat
  on paps.problem_and_problem_source_id = yat.join_column_name
where  paps.free_user_id is not null

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM