Home  >  Article  >  Database  >  How to write conditional statements for addition, deletion, modification and query of SQL database information? (example)

How to write conditional statements for addition, deletion, modification and query of SQL database information? (example)

藏色散人
藏色散人Original
2018-08-14 16:46:584329browse

This article mainly summarizes and introduces the addition, deletion, modification and query statements of the database. Everyone should know that SQL is the standard computer language used to access and manipulate databases. What are its main functions?
You can query the database, insert data into the database, update data in the database, delete data in the database, and add new data to the database.
(Database) is a warehouse that organizes, stores and manages data according to the data structure. With the development of information technology and market, data management is no longer just about storing and managing data, but transforming into various data needed by users. way of management.
The following is an example of adding, deleting, modifying and querying SQL statements:
1. Adding commonly used SQL adding, deleting, modifying and querying statements: insert into data table (field 1, field 2, field 3) values ​​(value 1, value 2, value 3 )

String sql="insert into employees(id,username,age) values(22,2,2)";

2. Deletion of sql statement additions, deletions and modifications: delete from data table where id=received ID parameter

String sql2="delete from employees where id=22";

  How to write conditional statements for addition, deletion, modification and query of SQL database information? (example)

3. sql table Modification of add, delete, modify and query: update data table set field 1=value 1, field 2=value 2 where id=received ID parameter

String sql3="update employees set username='zhang',age='2222' where id=1";

4. Query

String sql4="select * from employees where id=1";

The above is an introduction to the specific statements about addition, deletion, modification and query of sql database. I hope friends in need will have some knowledge about adding, deleting and modifying SQL statements.


The above is the detailed content of How to write conditional statements for addition, deletion, modification and query of SQL database information? (example). For more information, please follow other related articles on the PHP Chinese website!

Statement:
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