TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

MySQL From Clause

MySQL From Clause for beginners and professionals with examples on CRUD, insert statement, select statement, update statement, delete statement, use database, keys, joins etc.

<< Back to MYSQL

MySQL FROM Clause

The MySQL FROM Clause is used to select some records from a table. It can also be used to retrieve records from multiple tables using JOIN condition.

Syntax:

FROM table1
[ { INNER JOIN | LEFT [OUTER] JOIN| RIGHT [OUTER] JOIN } table2
ON table1.column1 = table2.column1 ]

Parameters

table1 and table2: specify tables used in the MySQL statement. The two tables are joined based on table1.column1 = table2.column1.

Note:

  • If you are using the FROM clause in a MySQL statement then at least one table must have been selected.
  • If you are using two or more tables in the MySQL FROM clause, these tables are generally joined using INNER or OUTER joins.

MySQL FROM Clause: Retrieve data from one table

The following query specifies how to retrieve data from a single table.

Use the following Query:

SELECT *
FROM officers
WHERE officer_id <= 3;
MySQL from clause 1

MySQL FROM Clause: Retrieve data from two tables with inner join

Let's take an example to retrieve data from two tables using INNER JOIN.

Here, we have two tables "officers" and "students".

MySQL from clause 2

Execute the following query:

SELECT officers.officer_id, students.student_name
FROM students
INNER JOIN officers
ON students.student_id = officers.officer_id;
MySQL from clause 3

MySQL FROM Clause: Retrieve data from two tables using outer join

Execute the following query:

SELECT officers.officer_id, students.student_name
FROM officers
LEFT OUTER JOIN students
ON officers.officer_id = students.student_id;
MySQL from clause 4



Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf