Home > Database > SQL > What is the difference between hql and sql

What is the difference between hql and sql

hzc
Release: 2020-06-15 13:19:19
Original
16021 people have browsed it

What is the difference between hql and sql

The difference between hql and sql in the database:

1. SQL is oriented to database table query.

2. hql object-oriented query.

3. hql: The class name + class object followed by from is followed by where, and the attributes of the object are used as conditions.

4. SQL: From is followed by the table name and where followed by using the fields in the table to perform conditional queries.

5. When using queries in Hibernate, Hql query statements are generally used.

6. HQL (Hibernate Query Language), that is, Hibernate's query language is very similar to SQL. However, the most fundamental difference between HQL and SQL is that it is object-oriented.

When using queries in Hibernate, Hql query statements are generally used.

HQL (Hibernate Query Language), Hibernate’s query language is very similar to SQL. However, the most fundamental difference between HQL and SQL is that it is object-oriented.

You need to pay attention to the following points when using HQL:

Case sensitivity

Because HQL is object-oriented, and the names and attributes of object classes are case-sensitive , so HQL is case-sensitive.

HQL statement: from Cat as cat where cat.id > 1; is different from from Cat as cat where cat.ID > 1;, which is different from SQL.

from clause

from Cat, this clause returns a Cat object instance, developers can also add aliases to it, eg. from Cat as cat, for multi-table queries, you can The reference is as follows:

from Cat as cat, Dog as dog

Other aspects are similar to SQL and will not be repeated here.

Recommended tutorial: "sql tutorial"

The above is the detailed content of What is the difference between hql and sql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
sql
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template