selecting from multiple tables sql using or code example
Example 1: how to select from two tables in sql
SELECT t1.name, t2.salary FROM t1 JOIN t2 on t1.id = t2.id;
SELECT t1.*, t2.salary FROM t1 JOIN t2 on t1.id = t2.id;
SELECT t1.name, t2.salary FROM t1 LEFT OUTER JOIN t2 on t1.id = t2.id;
SELECT emp_name AS name from employees
UNION
SELECT cust_name AS name from customers;
SELECT emp_name AS name from employees
UNION ALL
SELECT cust_name AS name from customers;
Example 2: sql query multiple tables
SELECT t1.name, t2.salary FROM t1 JOIN t2 on t1.id = t2.id;
SELECT t1.name, t2.salary FROM t1 LEFT OUTER JOIN t2 on t1.id = t2.id;
SELECT emp_name AS name from employees
UNION
SELECT cust_name AS name from customers;
SELECT emp_name AS name from employees
UNION ALL
SELECT cust_name AS name from customers;