查询端有月-年夫妇值。但是表格已将年份和月份的列分开。如果只有一对月-年(例如7-2013)没问题,
SELECT pik.pk_yil AS pkYil,
pik.pk_ay As pkAy,
krm.kurum_adi AS krmAdi,
ilc.ilac_adi AS ilcAdi,
pik.ilac_parti_no AS ilcPN,
pik.ilac_skt AS ilcSKT
FROM piyasa_kontrol pik
LEFT JOIN kurum_adlari krm ON pik.pk_il=krm.id
LEFT JOIN ilaclar ilc ON pik.ilac_id=ilc.id
WHERE pk_il=
(
SELECT evrak_gonderen
FROM evraklar
WHERE id=124 OR gelen_evrak_etakip=124
)
AND pik.pk_yil = 2012
AND pk_ay = 6
我应该如何设置查询中是否有一对以上,例如“ 7-2013、8-2013、3-2011”?同样,月份和年份也绑定了查询逻辑。
语言是php,数据库是mysql。
最佳答案
您只是在寻找or
吗?
WHERE pk_il = (SELECT evrak_gonderen
FROM evraklar
WHERE id=124 OR gelen_evrak_etakip=124
) AND
((pik.pk_yil=2012 AND pk_ay=6) OR
(pik.pk_yil=2013 AND pk_ay=7) OR
(pik.pk_yil=2013 AND pk_ay=8) OR
(pik.pk_yil=2011 AND pk_ay=3)
)