Last active
June 3, 2021 09:48
-
-
Save AbudiMutamba/5d2c102f129e7ba5beaefc149d0229f6 to your computer and use it in GitHub Desktop.
Retriving data in SQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Retrieving a specific number of rows; | |
-- SELECT * FROM demo LIMIT 3; | |
-- Retrieeving start after , number of rows | |
-- SELECT * FROM demo LIMIT 3,3; | |
-- Retrive while odering by id comuln in Ascending | |
-- SELECT * FROM demo ORDER BY (id) ASC; | |
-- Retrive while odering by id comuln in Descending | |
-- SELECT * FROM demo ORDER BY (id) DESC; | |
-- Therefore the ordering clause in my sql and mariadb syntax is ORDER BY(column name) | |
-- IFi you don't specify the DESC or ASc , the default is Ascending order; | |
/*SELECT * FRom demo | |
ORDER BY id,name; */ | |
/*SELECT * FROM demo | |
ORDEr BY id ASC, name DEsc;*/ | |
-- Customizing table | |
-- We use the ALTER keyword | |
/*ALTER TABLE demo | |
ADD date Date ;*/ | |
-- DESCRIBE demo; displsy | |
/*Alter TABLE demo | |
DROP DAte; | |
ALTER TABLE demo | |
ADD record_date DATETIME;*/ | |
/*INSERT INTO demo (name, hint, record_date) | |
VALUES ('Dsvid', 'Coach',NOW()),('Mark', 'Coach',NOW()),('Charles', 'Coach',NOW());*/ | |
-- SELECT * FROM demo; | |
-- DELETE FROM demo WHERE name = 'David'; | |
-- UPDATE demo SET name = 'David' WHERE hint = 'coach'; | |
-- SELECT * FROM demo; | |
-- UPDATE demo SET name = 'David' WHERE name = 'Dsvid'; | |
-- SELECT * FROM demo; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment