Error in SQL query

Asked

Viewed 35 times

1

Hello I have a table in the database that in it are stored several times. I am making a query only that this giving error.

Consultation:

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)

1 answer

3


I think there’s some confusion in your query. This ultimo is there too much, 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

  • Yes the mood is that, it worked, thank you very much!

  • You’re welcome! Give the answer as sure ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.