Error in SQL query

1

Hello, I have a table in the database that has several times stored in it. And I'm just making an appointment that is giving error.

Inquiry:

select proximo from (select localizacao.horario as proximo from localizacao where localizacao.horario > CURRENT_TIME LIMIT 1) as tb_proximo, ultimo FROM (select localizacao.horario as ultimo from localizacao where localizacao.horario < CURRENT_TIME) as tb_ultimo;

Error:

2 errors were found during analysis.

This type of clause was previously parsed. (near "FROM" at position 148)
Unrecognized statement type. (near "FROM" at position 148)
    
asked by anonymous 01.10.2018 / 13:12

1 answer

3

I think there is some confusion in your query. This ultimo is there more, as well as the 2nd FROM .

Try it this way:

SELECT  (
            SELECT  localizacao.horario AS proximo 
            FROM    localizacao 
            WHERE   localizacao.horario > CURRENT_TIME LIMIT 1
        ) AS proximo
    ,   (
            SELECT  localizacao.horario AS ultimo 
            FROM    localizacao 
            WHERE   localizacao.horario < CURRENT_TIME
        ) AS ultimo
    
01.10.2018 / 13:18