[英]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.