Fetching Data from the Table
Now let’s fetch the data from this table. As we have used reserved words as identifiers in our table, we have to enclose them in backticks if we want to use them as identifier. Let’s implement this using a query where we use both reserved words and reserved words as identifiers.
SELECT
m1.order_id,
m1.`GROUP`,
m1.`Table`
FROM
MyTable m1
JOIN
MyTable m2 ON m1.order_id = m2.order_id
WHERE
m1.`GROUP` > 5
ORDER BY
m1.`Table`;
Output:
order_id |
GROUP |
Table |
---|---|---|
5 |
9 |
2 |
4 |
12 |
4 |
3 |
8 |
11 |
Explanation: As shown in the above table, we have used included reserved words and reserved words as identifiers. So if we want to use reserved words as identifier, we have to enclose it in backticks(`) as shown in the query.
MySQL Reserved Words
MySQL is a popular and widely used Relational Database Management System. Like any programming language, MySQL has its own set of reserved words. Reserved words are specific terms or keywords with predefined meanings within the database system. It is very important to know the reserved words to avoid conflicts in the execution of the queries.
Contact Us