查询方面有月 - 年夫妇值。但是表格分列了年份和月份。如果只有一个月 - 年对(例如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,db是mysql。
答案 0 :(得分:1)
您是否只是在寻找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)
)