-1

This could be a repost; if so, link me and I will delete.

First off, I am a SQL newb. I have two tables, table_1 and table_2. I want to select the column names from table_1 that only correspond to values found in a column named 'foo' from table 2.

How can I got about this? Does this require an inner join?

I have some code I can post, but it is a disaster.

branch.lizard
  • 595
  • 1
  • 5
  • 15

1 Answers1

1

These is one type of example.

select * from table1 join table2 on table1.col1= table2.col2

we follow these above syntax.

select * from table1 join table2 on table1.col1= table2.foo

These is the how find out column_name is present in another table

SELECT * FROM(    SELECT letter  FROM `Table_2` ) a JOIN
(SELECT `COLUMN_NAME` 
FROM `INFORMATION_SCHEMA`.`COLUMNS` 
WHERE `TABLE_SCHEMA`='database_name' 
    AND `TABLE_NAME`='Table_1') b ON a.letter= b. COLUMN_NAME

Thank you.

Venkatesh Panabaka
  • 2,064
  • 4
  • 19
  • 27