-3
I have a select normal
SELECT campos FROM tabela_Z WHERE condicoes
I’d like that one query add a field that is another query.
SELECT
campo1,
campo2,
campo3,
(SE houver o id X na TABELA _, = true, caso contrario = false)
FROM tabela_Z
WHERE condicoes
How to do this?
It would be something like that I need:
SELECT
membros.idMembro,
membros.nome,
membros.apelido,
membros.bloqueado,
membros.usuario,
membros.senha,
acessos.idAcesso,
acessos.nome
(SELECT IF(admins.idMembro=1, 's', 'n') FROM admins)
FROM membros , acessos, acessosmembros
WHERE
membros.usuario ='caca' AND
membros.senha ='aaaa' AND
acessosmembros.idMembro = membros.idMembro AND
acessosmembros.idAcesso = acessos.idAcesso
If I do
SELECT IF(admins.idMembro=1, 's', 'n') FROM admins
In the phpmyadmin, have correct return.
But I need to insert it into one of the selects of query
This guy
id Xis in the same table? If there is more than one result in the query, all will return the sametrueorfalsesince in the consultation will be passed only oneid X, right?– LipESprY
search by Mysql IF() Function example https://www.w3schools.com/sql/func_mysql_if.asp see also https://www.w3resource.com/mysql/control-flow-functions/if-function.php
– user60252
this id x is not in the same table. It’s kind of to add a field to the Array that will be populated by the result of this query
– Carlos Rocha
I added details to the question!
– Carlos Rocha
It worked, missing a comma at the end of hits.
– Carlos Rocha