subquery - mysql sub query has has one query return no row which in turn return no final rows -


i have 2 tables 1 md_waiting_slot_count , second has md_slot_count has column bellow.

md_waiting_slot_count  cell,                                           date,         userid,  creationtiem '2017-08-05_gujarat_rajkot_rajkot_23-27_male', '2017-08-17', 'abcdef', '2017-08-17 16:45:02'  md_slot_count   id,                                         date,       filledslotcount '2017-08-05_gujarat_rajkot_rajkot_23-27_male', '2017-08-17', 1 

now case md_waiting_slot_count contain temporary data , represent "which cell allocated user on particular date." table md_slot_count contain final data , represent "one cell has how many user allocated on 1 particular date", here user has cell allocated not important in table.

now want query data has bellow. " table md_waiting_slot_count need count each cell has how many time repeat on 1 particular date want filledslotcount table md_slot_count same cell , same date , make addition on count , check value after addition of both count less 4."

i have make query same , bellow.

(select cell,t1.totalcount, t2.id,t2.filledslotcount, (t1.totalcount + t2.filledslotcount) totalcount   (select cell, count(cell) totalcount md_waiting_slot_count wc popupdate="2017-08-05" ,  creationtime < date_sub(now(), interval 20 minute) , cell in("2017-08-05_gujarat_rajkot_rajkot_23-27_male") group cell) t1 , (select id, filledslotcount md_slot_count popupslotdate="2017-08-05" ,   id in("2017-08-05_gujarat_rajkot_rajkot_23-27_male")) t2  having totalcount < 4) 

now work fine in case when have matching row in both table.

the problem occurs when second sub query after "," return no row, in case outer query make total using "(t1.totalcount + t2.filledslotcount) totalcount" not work , not return rows.

so in case there no row in table match clause of second sub query , return no row.

actually want total count after addition of both individual count value in case, finds row or not in of table.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -