我有两张表产品和规范。在产品表中,有 PhoneMake、PhoneModel 和 ProductId 等列,而在规范中,有 Os_name、Dapps、Os_ram、ProductId 等列。我的问题是如何从所有这些中选择多个列值。 喜欢
select *
from product
where true
AND PhoneMake ='Motorola'
AND PhoneMake ='Nokia '
AND specs.Os_name ='on'
AND specs.Os_name ='on'
AND specs.Dapps ='on'
AND specs.Os_ram =512
AND specs.Os_ram =1
正确的 mysql 查询是什么?
最佳答案
您必须了解联接:
select * from product join specs on <condition>
where PhoneMake in ('Motorola','Nokia') AND specs.Os_name ='on' AND specs.Dapps ='on'AND specs.Os_ram IN(512,1)
这是与表的简单连接。 <conditon>
必须更改 specs
之间的外键关系和product
.
关于mysql - 如何在mysql中从不同表名具有不同值的多个列中选择?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28145644/