I want to get the result ordered by the same order of the list, but it keeps giving errors.
select "Usuario"."nombre", "Usuario"."codSis"
from "public"."Usuario"
where "codSis" in (6, 8)
order by field(codSis ,6,8)
this code gives mi this error
ERROR: column "codsis" does not exist
LINE 4: order by field(codSis ,6,8)
^
HINT: Perhaps you meant to reference the column "Usuario.codSis".
SQL state: 42703
Character: 112
but when I put this
select "Usuario"."nombre", "Usuario"."codSis"
from "public"."Usuario"
where "codSis" in (6, 8)
order by field(Usuario.codSis ,6,8)
it gives me this error
ERROR: column "Usuario.codSis" does not exist
LINE 4: order by field("Usuario.codSis" ,6,8)
^
SQL state: 42703
Character: 112
then I tried this
select "Usuario"."nombre", "Usuario"."codSis"
from "public"."Usuario"
where "codSis" in (6, 8)
order by field("Usuario"."codSis" ,6,8)
and it gave me this error
ERROR: function field(integer, integer, integer) does not exist
LINE 4: order by field("Usuario"."codSis" ,6,8)
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
SQL state: 42883
Character: 106
order by fieldis mysql, postgresql doesn't have thatorder by codSis?order by fieldstatement not being a Postgres one. The second is identifier quoting. If an identifier is created in upper or mixed case by being quoted("codSis" ) then it needs to be used that way from then on. For more information see: Identifiersfield()function to do?