Today, We want to share with you sql examples.In this post we will show you sql interview questions, hear for sql commands with syntax and examples we will give you demo and example for implement.In this post, we will learn about sql online tutorial with an example.
sql queries examples with answers
In this tutorial we learn to all about sql examples Examples like as a SQL SELECT, WHERE, AND, OR and NOT Operators, MIN() and MAX(), COUNT, AVG() and SUM() or many more.
Also Read: sql subquery examples
SQL SELECT
SELECT MemberName, Location FROM Members;
SELECT * Example
SELECT * FROM Members;
SQL SELECT DISTINCT
SELECT DISTINCT Districts FROM Members; //or SELECT Count(*) AS DistinctCountries FROM (SELECT DISTINCT Districts FROM Members);
SQL WHERE
SELECT * FROM Members WHERE Districts='Surat';
SQL AND, OR and NOT Operators
SELECT * FROM Members WHERE Districts='Jammnagar' AND Location='Bhavanagar'; SELECT * FROM Members WHERE Location='Bhavanagar' OR Location='Paladi char rasta'; SELECT * FROM Members WHERE NOT Districts='Jammnagar';
SELECT * FROM Members WHERE Districts='Jammnagar' AND (Location='Bhavanagar' OR Location='Paladi char rasta');
SQL ORDER BY
SELECT * FROM Members ORDER BY Districts DESC;
SQL INSERT INTO
INSERT INTO Members (MemberName, ProfileNm, Address, Location, PostalCode, Districts) VALUES ('Bhakti', 'Soratiya B. Jala', 'Dhara 21', 'Om Nagar', '360002', 'Rajkot');
SQL NULL Values
SELECT MemberName, ProfileNm, Address FROM Members WHERE Address IS NULL;
SQL Update
UPDATE Members SET ProfileNm = 'Ajmera Hitesh', Location= 'Gondal Chokadi' WHERE MemberID = 1;
UPDATE Multiple Records
UPDATE Members SET ProfileNm='Munoj' WHERE Districts='Surat';
SQL DELETE
DELETE FROM Members WHERE MemberName='Chanagani Yagnika'; // Delete All Records DELETE FROM tamilrokers_tbl;
SQL SELECT TOP
SELECT TOP 3 * FROM Members; //or SELECT * FROM Members LIMIT 3;
SQL MIN() and MAX()
SELECT MIN(Amount) AS SmallestAmount FROM Mobiles;
SELECT MAX(Amount) AS LargestAmount FROM Mobiles;
SQL COUNT, AVG() and SUM()
SELECT COUNT(MobileID) FROM Mobiles;
SELECT AVG(Amount) FROM Mobiles;
SELECT SUM(Quantity) FROM OrderDetails;
SQL LIKE
SQL Wildcards
SELECT * FROM Members WHERE Location LIKE '%mn%'; //or SELECT * FROM Members WHERE Location LIKE '_try'; //or SELECT * FROM Members WHERE Location LIKE 'M_k_pi'; //or SELECT * FROM Members WHERE Location LIKE '[jdk]%';
SQL IN
SELECT * FROM Members WHERE Districts IN ('Jammnagar', 'Surat', 'Ahemdabad');
SQL BETWEEN
SELECT * FROM Mobiles WHERE Amount BETWEEN 10 AND 20;
SQL Aliases
SELECT MemberID AS ID, MemberName AS Member FROM Members;
I hope you get an idea about sql examples.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.