php - mysql query where conditions -


i have mysql database, here columns;

date

computerlab

period


only 2 possible data values go computerlab column, a101 or a102

however, there can duplicate rows of data different computerlab data

for example,

date = 3-15-16 computerlab = a101 period = 1

date = 3-15-16 computerlab = a102 period = 1


my webpage gets input user receiving several periods 1,3,5

this need:

if period 1 or 3 or 5 contains both a101 , a102 return date


i think work doesn't

mysql_query("select date reservations period in ($periods) , lab in ('a101','a102') group date having count(*) = 2"); 

i think need group both period and date want:

select date, period reservations period in ($periods) , lab in ('a101', 'a102') group period, date having count(*) = 2; 

this check given period has both labs. checking set of 3 periods had 2 entries.

hmmm, realize might intend check if 3 periods had both labs assigned, in combination. if use count(distinct):

select date reservations period in ($periods) , lab in ('a101', 'a102') group date having count(distinct lab) = 2; 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -