Hello friends, I’m going to discuss the second part Learn MySQL Important Queries, In the previous part, we learned basic and essential part of MySQL queries. In this part, we’ll learn about some advanced query that will help you in RDBMS (Relational Database Management System).
ALTER TABLE
Add Column
The syntax to add a new column to an existing table is:
ALTER TABLE Student ADD COLUMN LastName Varchar(50);
You can also define where the column is going to place.
ALTER TABLE Student ADD COLUMN LastName Varchar(50) AFTER RollNo;
Delete Column
The syntax to delete an existing column is:
Any data contained in a dropped column will be deleted as well.
ALTER TABLE Students DROP COLUMN photo;
Rename Table
To Rename the entire table, the syntax is:
ALTER TABLE Students RENAME TO Student_details;
Operators
MySQL queries can benefit from the use of several operators and clauses.
SELECT * FROM Studen WHERE name LIKE '%T%' AND gender LIKE 'Female'; SELECT * FROM Student WHERE (name LIKE 'Kumar ' AND gender LIKE 'male') OR (Name LIKE 'Rahul' AND gender LIKE 'male');
Distinct
We use DISTINCT to avoid duplicate value
SELECT DISTINCT name FROM student ORDER BY name;
Count
The COUNT() function is used for count the rows.
SELECT COUNT(*) FROM student;
Also View: –
Extract Data in Excel From MySQL database using PHP in Specific Date Range
I hope this post helped you to know Learn MySQL Important Queries – Part 2. To get the latest news and updates follow us on twitter & facebook, subscribe to our YouTube channel. And If you have any query then please let us know by using the comment form.
md hafiz says
very halpful post thanks
Jamaley Hussain says
Thanks For Stopping and Commenting here. I’m glad to know that you like the Post. Keep Visiting.
Asif says
Thank you, I am able to fix my project.