SQL | SELECT data from Multiple Tables
SELECT tablenmae1.colunmname, tablename2.columnnmae
FROM tablenmae1
JOIN tablename2
ON tablenmae1.colunmnam = tablename2.columnnmae
ORDER BY columnname;
SQL | SELECT data from Multiple Tables
SELECT tablenmae1.colunmname, tablename2.columnnmae
FROM tablenmae1
JOIN tablename2
ON tablenmae1.colunmnam = tablename2.columnnmae
ORDER BY columnname;
how to select from two tables in sql
-- With JOIN
-- No row if id does not exist in t2
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;
-- A row with a NULL salary is returned if id does not exist in t2
SELECT t1.name, t2.salary FROM t1 LEFT OUTER JOIN t2 on t1.id = t2.id;
-- With UNION: distinct values
SELECT emp_name AS name from employees
UNION
SELECT cust_name AS name from customers;
-- With UNION ALL: keeps duplicates (faster)
SELECT emp_name AS name from employees
UNION ALL
SELECT cust_name AS name from customers;
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us