Chandra
Chandra

Reputation: 41

Is there any way in MySQL, to create a single select statement where the select column is the result of another query?

My first select statement would be like below,

SELECT m.col_name
     , m.col_alias
  FROM <table_name> m 
 WHERE m.exportable LIKE '%Y%'

And I'm trying to create a second select query with the data that I'm receiving from the first statement, like below

SELECT tabella.id alias_1
     , tabella.value alias_2
     , **“list of col_name result of the previous query”
  FROM <another_table> tabella
 WHERE tabella.metadata_id = 'CI_INDEX||CI_01'*

Thanks in advance.

Upvotes: 0

Views: 68

Answers (2)

Md. Mahmud Hasan
Md. Mahmud Hasan

Reputation: 1063

Try the Subquery. You will find an example in the links.

Upvotes: 2

abhinav
abhinav

Reputation: 31

If the tables have relation between them then go for Join

if the tables do not have relation you can use the following format.

select table1.col1,table2.col1 from table1, table2
where table1.colx like '%exp%' and table2.coly like '%exp2%'

Upvotes: 0

Related Questions