我想在我的getadvocacy表中选择某一行,其中id是另一个表中的id,称为Swimsuit。
泳衣桌
id | name | average
1 | Abc | 90
3 | Def | 99
宣传
id | all_scores | average_score
1 | 70,70,70 | 70
2 | 70,70,70 | 70
3 | 70,70,70 | 70
现在,我要从getadvocacy中进行选择,但只能选择1和3,因为它是泳衣上的数据。
预期产量
id | all_scores | average_score
1 | 70,70,70 | 70
3 | 70,70,70 | 70
我试过了,但是它有不同的输出。
select getadvocacy.id, all_scores, average_score from getadvocacy WHERE getadvocacy.id IN (select id from swimsuit)
如果表的ID(主键)相同,则可以在ID上使用join
select * from table1
JOIN table2
on table1.id = table2.id
用这个
select * from swimsuit JOIN getadvocacy ON swimsuit.id= getadvocacy.id;
查询结果是
1 abc 90 1 50,60,70 70
3 def 99 3 60,70,70 70
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句