Jump to content
Fórum Script Brasil
  • 0

Mostrar o resultado da pesquisa


foxbh
 Share

Question

Bom dia pessoal, preciso mostrar para o cliente o resultado a partir de uma consulta SQL, já fiz, deu o retorno certinho, porem não estou conseguindo exibir para o cliente. 
O alias QT eu recebo normamente e exibo, agora como consigo criar um Segundo ALIAS para receber o ( geral_ava )

Exemplo funcionando  http://sqlfiddle.com/#!9/23cfaf/6

SELECT *, (SELECT COUNT(*) FROM avaliacao WHERE id_car_ava=id_car ),(SELECT SUM(geral_ava) FROM avaliacao WHERE id_car_ava = id_car ) AS QT FROM carros
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Utilize a cláusula/comando AS para deixar todos com apelido (alias):

SELECT
		*,
		(SELECT COUNT(*) FROM avaliacao WHERE id_car_ava=id_car ) AS apelido_blablablah,
		(SELECT SUM(geral_ava) FROM avaliacao WHERE id_car_ava = id_car ) AS QT
	FROM carros

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Forum Statistics

    • Total Topics
      149.9k
    • Total Posts
      646.8k
×
×
  • Create New...