HMShingala

A list of commonly used MySQL queries to create and how to use database, create table, insert record, update record, delete record, select record, truncate table and drop table are given below.

Create database:

CREATE DATABASE test_database

Create new table:

CREATE TABLE user (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR(30) NOT NULL,
email VARCHAR(50),
birthdate TIMESTAMP
)

Insert data into table:

INSERT INTO MyGuests (firstname, lastname, email)
VALUES ('Harshit', 'Shingala', 'harshit@mail.com')

Select data all from table:

SELECT id, firstname, lastname FROM MyGuests

Select data from table using Where cluse:

SELECT firstname, lastname FROM MyGuests WHERE id=2

Delete data from table:

DELETE FROM MyGuests WHERE id=3

Update data:

UPDATE MyGuests SET lastname='Doe' WHERE id=2

select data with limit:

SELECT * FROM Orders LIMIT 30

Leave a Reply

Your email address will not be published. Required fields are marked *