I have a problem to finalize a project, I need to return the records of a database table, but in some registers, it has a data stored differently, so I need to stop the execution. I could not find the solution so far.
What I need is to show as a result, how many records are with the status column 0
, limiting at most 6
records, if they have other records after 2 registers with 0
status, stop execution.
Example:
Tabela: 11_07_2017_sala1
id | matricula_aluno | entrada | saida | status
1 | 0 | 6.5 | 7 | 0
2 | 0 | 7 | 7.5 | 0
3 | 2 | 7.5 | 8 | 1
4 | 2 | 8 | 8.5 | 1
5 | 2 | 8.5 | 9 | 1
6 | 0 | 9 | 9.5 | 0
When I made Query with the WHERE status = 0
clause, it jumped the records that are with status = 1
, but continued to display the results of the other records.
I added LIMIT 6
, however, the records kept returning all, except for those where status = 1
, limiting to 6 records.
What would be the correct way for this application?
Thank you!