1
I have a problem to finish a project, I need to return the records of a database table, however, in some records, have a data stored differently, so I need to stop the execution. I haven’t been able to find the solution so far.
What I need is: Display as a result, how many records are in the status column 0
, limiting to a maximum 6
records, if they have other records after 2 records with status 0
, stop the 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 Query with the clause WHERE status = 0
, skipped the records that are with status = 1
, but continued to display the results of other records.
I added LIMIT 6
, however, the records continued to return all, with the exception of those in which the status = 1
, limiting to 6 records.
What would be the correct form for this application?
Thanks!
Can you be clearer? I personally couldn’t understand what you want to do. If possible, give examples of the two situations: when to stop execution and when not to.
– Woss
The problem is no limit. can you post your querie? I can imagine what it is!
– Rafael Salomão
Query with clause WHERE and LIMIT: SELECT * FROM 11_07_2017_sala1 WHERE status = 0 LIMIT 6 Can return more records if status = 0 Cannot return if next record status = 1
– Hugo Christian