SQL Tutorials

Step-by-step lessons for beginners. Copy the code, run it in your editor, and start building real websites.

Xampp Installation

Learn how to install Xampp server:

step 1- Open your browser and go to: 👉 www.apachefriends.org

HTML Example

step 2- Click on XAMPP for Windows to download the latest version.

HTML Example

step 3- Click on green colour botton (download latest version)

HTML Example

step 4- For installation use Local Disk(C)

HTML Example

step 5- After installation click start of Apache and MySql, then minimize the window.

HTML Example

CMD command

Start xampp server with cmd command.

HTML Example

Create database

Create database in xampp server.

HTML Example

Show databases

Show created databases.

HTML Example

Use database

Use created database.

HTML Example

Create table university

Create a new table in database.

HTML Example

Desc university

Show structure of the university table.

HTML Example

Create table student

Create another new table in database.

HTML Example

Desc student

Show structure of the student table.

HTML Example

Insert into university

Enter data into university table.

HTML Example

Insert into student

Enter data into student table.

HTML Example

Select all from university

Show data in all columns in university table.

HTML Example

Select all from student

Show data in all columns in student table.

HTML Example

Select name from student

Displays only the name column from the student table.

HTML Example

Select name as "Undergraduates" from students

Displays the name column, but the output heading is renamed to Undergraduates.

HTML Example

Select indexno, name from students

Shows only the index number and name columns from the students table.

HTML Example

Select indexno, name as "Undergraduates" from students

Shows the index number and the name column, but names are displayed under the heading Undergraduates.

HTML Example

Select indexno, name as "Undergraduates" from students Order By indexno Desc

Displays index number and name (as Undergraduates) sorted by index number in descending order (largest to smallest).

HTML Example

Select indexno, name as "Undergraduates" from students Order By name Desc

Displays index number and name (as Undergraduates) sorted by name in descending alphabetical order (Z → A).

HTML Example

Select distinct name from students

Shows only unique names from the students table (removes duplicates).

HTML Example

ALTER table university

Used to modify the structure of the university table (e.g., add, delete, or change columns).

HTML Example

Desc university

Shows the structure (columns, types, keys) of the university table.

HTML Example

Select all from university

Displays all data from the university table.

HTML Example

Update university

Used to change/update data in the university table.

HTML Example

Select all from university

Displays all data from the university table

HTML Example

Select payment from university where name like 'university of technology'

Shows the payment column for the university named “university of technology”.

HTML Example

Select payment all 1000 as "Income" from university where name like 'university of technology'

Adds 1000 to the payment and shows it under the heading Income.

HTML Example

Select count (IndexNo) from student where uniid like 'UOO1'

Counts the number of students in the student table whose university ID is UOO1.

HTML Example

📊 Learn SQL Basics (W3Schools)

Want to work with databases? Learn how to use SQL to store, manage, and retrieve data efficiently. Start with the basics of SELECT, INSERT, UPDATE, and DELETE commands in this beginner-friendly tutorial. 👉 Learn SQL on W3Schools

← Back to LearnScience