php - Merging two queries with the same binded parameter -


I first getting a table with id_member as a SQL query parameters

  $ Stmt = $ Mysqli - & gt; Select up ( "a.id_alerte, a.nom_alerte, ar.id_roster, r.nom_roster, the alert one, alerte_par_roster ar, roster_par_membre rm where r.id_roster = rm.id_roster on insider who roster r rm.id_roster = ar .id_roster and Ar.id_alerte = a.id_alerte and rm.id_membre =? "); $ Stmt- & gt; Bind_param ('i', $ id_membre);  

I need to put a second query to count the number of rows in the second table.

The second question is:

  "? COUNT selected in (where different id_roster) disponibilites_par_member_alertes id_member = and id_alerte ="  

You can notice id_member is similar in both queries but id_alerte (the second query is a result of a first query used as a parameter). I hope I am clear any thoughts will be very welcome

I do not fully understand That's what you have to do. This table will help you get clear information on the structure and how each field will represent. I have tried to guess based on the name of the table but it is not certain that it is correct.

The first thing I did was to change your WHERE status, only. It is for readability

  select a.id_alerte, a.nom_alerte, ar.id_roster, alert the r.nom_roster an insider who alerte_par_roster ar on ar.id_alerte = a.id_alerte Insider Join to include rm.id_roster = Ar.id_roster INNER roster R roster_par_membre rm r.id_roster = rm.id_roster WHERE rm.id_membre =?  

Now we combine with other questions: