[Solved] SQL select from 2 tables where 2 condition [closed]


If you just want to return the rows from each table that match, then you can use a UNION ALL:

SELECT * 
FROM Table1 
WHERE column2 = 1 
union all
SELECT * 
FROM Table2 
WHERE column22= 1;

See SQL Fiddle with Demo

If you want to return the rows that match both criteria, then possibly you want to JOIN the tables:

SELECT * 
FROM Table1 t1
INNER JOIN Table2 t2
  on t1.column1 = t2.column11
where t1.column2 = 1
  and t2.column22 = 1;

See SQL Fiddle with Demo

solved SQL select from 2 tables where 2 condition [closed]