Return columns according to sql server criteria?

Asked

Viewed 73 times

0

How could I return the column names of a table according to search criteria? I want to return the columns that are with option’S', all fields is a char of 1 that takes "s" or "n"

select 
   b.livros,
   b.jogos,
   b.cinema
from
   tb_cadastro_usuario a 
   inner join tb_assuntos_interesse b on a.idusuario = b.idusuario
  • Do you want to know if the user is interested in books and/or games and/or cinema? Example, I am registered and interested in movies and games... When seeking me by the ID you would return Interests: Games, Cinema ? Type issio?

  • 1

    Where (b.livros = ’s' or b.jogos = ’s' or b.cinema = ’s') a bad model however because if you want to include 'theater' you need to create another column, think about a INTERESTS table and an INTERESSE_USUARIO link.

  • you either change the name of the columns either way, you can detail better, or by what you expect from your select

No answers

Browser other questions tagged

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