Select with a return of several values from several columns

Asked

Viewed 67 times

2

Greetings! This is my first post, I hope I can be helped and also help a lot in this journey with you! So any formatting error ask only patience until the patterns here are adequate!

Well, my first problem is creating a select that returns several values that are not in a single column of a table.

I need to do this to return research suggestions.. For example: If the employee type: "tec" is loaded by the database the possible phrases with it: for example: common keyboard, gamer keyboard, tec_fabricant, etc...

Maybe I have to use a nested select, but I’m still not sure:

Below is a scope of my need: Select * from tableEspecifica Where column_name like '%tec%';

Disregard primary key.

Sincerely yours.

  • Publish the template of your tables, the BD you are using (version etc.), which environment you use for front-end etc., something else this question is recurring and a simple search will return you much material that will help you.

  • There is no model in the tables, there are only two, Customer and Products, no DER diagram was made, it is just a job for the College!

  • In this case a type like (coluna1 like '%tec%' or coluna2 like '%tec%' ...) would solve.

  • yes, but select? how would you have all data channeled into a single Aliase?

  • I do not know if I understood your question but let’s say , if you search product , manufacturer, category etc if one or more of the columns "hit" you list , would be this ?

  • For example I have a table with Coluans A, B and C respectively, I want to independent of the column, back ALL values starting with the word 'tec%' with an ORDER BY DESC at the end! so the person when type in the search comes in Databind All possible searches of that name, so if the employee does not know the name of the distributor but knows the name of the product, it may fall as a suggestion!

  • the key word would be "collection and ordering...." independent of the column, capitura and plays in the output...is the same thing that google does when Voce starts typing in his search and it brings suggestions... the idea is this!

Show 2 more comments

1 answer

0


I managed to solve the problem, follow the steps below for future solutions in case someone needs:

SELECT colunaA as ApelidoPadrao

FROM tabelaA

Where colunaA like '%Suamensagem%'

UNION -- Esse é o cara que permite a junção

SELECT colunaB as ApelidoPadrao

FROM tabelaA

Where colunaB like '%Suamensagem%';

Okay! Make it two makes it more: It requires guys to be the same. However you can use a `SELECT TO_CHAR(Colunax) if you need to force one casting!

Browser other questions tagged

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