1
I am trying to assemble a query to search results in a table where I need to determine a condition for one column, group by another and Display a third.
The database consists of 6 Tables, 5 of which are consulted individually, containing: id
, entrada
, saida
, status
, materia
, exibir_entrada
, exibir_saida
, compartilhada
.
Below is the image of the base structure of the tables:
So far, I can get a query grouping by matter. I did the query like this:
$QueryBuscarAgruparMaterias = "SELECT count(*),materia FROM $NomeSala GROUP BY materia HAVING materia = 'Geografia'";
$ExeQrBuscarAgruparMaterias = mysql_query($QueryBuscarAgruparMaterias);
while ($MateriasAgrupadas = mysql_fetch_assoc($ExeQrBuscarAgruparMaterias)){
?>
<option value="<?php echo $MateriasAgrupadas['entrada'] ?>">
<?php echo $MateriasAgrupadas['entrada'] ?>
</option>
<?php
}
But the result does not present the information I need:
I even tried to make a SELECT COMPOSITE:
select entrada, count(materia) from
(
select*from
(
select * from $NomeSala WHERE compartilhada = 1 AND materia = 'Geografia'
)
)as t GROUP BY materia;
Even so, I can’t display the column logs entrada
.
The data of this query will be used to insert a new record in another table, thus generating a schedule of classes, both shared and private.
The other values will be stored in a table with the schedules of the day as shown in the picture 03_01_2017
. That’s where I need to enter the information.
What do the columns mean
status
andcompartilhada
? What are the valid values of these columns? They concern the matter, the room, the schedule of the room in question, or something else?– Victor Stafusa
In the Status, 0 = free | 1 = busy (Filter to insert new schedules). In shared, 0 = Not Shared | Shared (Show Time Shared Case = 1)
– Hugo Christian