Skip to content
Advertisement

SQL query, where = value of another table

I want to make a query that simply makes this, this may sound really dumb but i made a lot of research and couldn’t understand nothing.

Imagine that i have two tables (table1 and table2) and two columns (table1.column1 and table2.column2).

What i want to make is basically this:

SELECT column1 FROM table1 where table2.column2 = '0'

I don’t know if this is possible.

Thanks in advance,

Advertisement

Answer

You need to apply join between two talbes and than you can apply your where clause will do work for you

select column1 from table1 
   inner join table2 on table1.column = table2.column
   where table2.columne=0

for join info you can see this

Reading this original article on The Code Project will help you a lot: Visual Representation of SQL Joins.

alt text

Find original one at: Difference between JOIN and OUTER JOIN in MySQL.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement