Within the routine of those who work with databases, some commands are indispensable for the activities to be carried out. Commands of query, insert, update and registration of exclusion are some of them and we will explain how each of them works in MySQL as following.

SELECT MYSQL

The SELECT command is used to return all the records of a particular table in the form of consultation. The syntax used in MySQL is:

SELECT [Fields]

FROM [Table]

Exemple:

SELECT *

FROM products

The command allows that all or certain columns are displayed. For that, you just need to indicate the name of each column or use the character (*), as shown in the previous example. It can still have a WHERE conditional, used in filters. With it, the only the record that meets the conditional will be displayed.

SELECT *

FROM products

WHERE code = 2

In the example, only the registration of the product table that has the code 2 will appear.

INSERT MYSQL

Inserting a record in MySQL is through the INSERT command. Tables, columns, and also the values that are stored on it are indicated.

INSERT INTO [Table] ([Columns]) VALUES ([Values]);

Exemple:

INSERT INTO product (code,name) VALUES (1,’television’);

UPDATE MYSQL

The record update command in MySQL is the UPDATE. Its structure is shown below:

UPDATE [Table]

SET [Column] = [Value]

This more generic framework can be used to update all of the table at once, but this is totally inadvisable. Ideally, when you update a record in a table is that the WHERE conditional is present, thus avoiding possible failures.

UPDATE product

SET name = ‘TV’;

WHERE code = 1

In the example above, only the record with code 1 will have its value changed.

DELETE MYSQL

Just as the UPDATE command, the DELETE one will need to be used very carefully. This is because, when updating or deleting a database record, it may not be redeemed – only with restoring a backup that will be possible. The command syntax is very simple and should also be used with a conditional, as shown in the following example:

DELETE FROM [table] WHERE [conditional]

Exemple:       

DELETE FROM product WHERE code = 1

Check out more content on our blog!
Learn all about Scriptcase.

By ,

June 23, 2015

a

You might also like…

No-code: Ease or Trap? What no one tells you about creating without coding

With the popularization of No-code and Low-code platforms, application development has reached a po...

Top 10 Rapid App Development Tools You Need to Know

In this highly fast-moving digital world, rapid application development tools must be available to ...

You might also like…

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at sales@scriptcase.net. Learn more about our Privacy Police.