Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

MySQL cheat sheet

The MySQL Cheatsheet provides a comprehensive overview of MySQL elements, including data types, commands for creating and manipulating databases, and functions for data retrieval and calculations. It covers essential topics such as SQL constraints, joins, and aggregate functions, along with examples of how to use them. This resource serves as a quick reference for programming with MySQL, aiding in efficient database management and query execution.

Uploaded by

bharath.rit
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
4 views

MySQL cheat sheet

The MySQL Cheatsheet provides a comprehensive overview of MySQL elements, including data types, commands for creating and manipulating databases, and functions for data retrieval and calculations. It covers essential topics such as SQL constraints, joins, and aggregate functions, along with examples of how to use them. This resource serves as a quick reference for programming with MySQL, aiding in efficient database management and query execution.

Uploaded by

bharath.rit
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 13
11225, 9:49AM MySQL Cheatshest | CodewnhHary

Where ; DISTINCT Keyword It will retrieve only alstinet data ie. duplicate data rows will get eliminated Select DISTINCT ¢co ALL Keyword It etriove al the data ofthe selected column Column Aliases Its used to gio a temporary name to @ table or @ column in a table forthe purpose ofa particular query select. , AS Condition Based on a Range It wil only retrieve data of those columns whose values wil fll between valuel and valve? (both inclusive) Select «cote 12> Where Between ; Condition Based on a List Select * from IN (, , Select * fron Where NOT IN (,,);7 Condition Based on Pattern Match ntps:www-codewihharry.comblogpostinysql-cheatsheet! ans 11225, 9:49AM MySQL Cheatshest | CodewnhHary Select «colt», Where LIKE ‘t Searching NULL Itretums data that contains @ NULL value in them Select , SQL Constraints SQL constraints ore the rules or checks enforced on the deta columns of a table NOT NULL It ill ereate @ table with NOT NULL constraint to ite first column écoli> NOT NULL écol3> ); DEFAULT DEFAULT constraint provides a default value to @ column Create table UNIQUE UNIQUE constraint ensures tht oll values in the column are different Create table UNIQU ntps:www-codewihharry.comblogpostinysql-cheatsheet! 513 11225, 9:49AM MySQL Cheatshest | CodewnhHary CHECK constraint ensures that all values in @ column satisfy certain conditions: create table CHECK (condition) type): Primary Key Primary key is used to uniquely identity each row in a table Foreign Key RIMARY KEY (Orders ) REFERENCES Persons(PersonzO) wing Table Structure Desc or Describe command Itallows you to see the table structure Modifying Data Update Command Itwil update the valves of selected colurans Update SET = ) = ntps:www-codewihharry.comblogpostinysql-cheatsheet! ens 12726, 949 AM MySQL Cheatsheet | CodeinHanry order by clause It will return records inthe ascending order of te specified column name's date elect * from order by DESC Ordering data on multiple columns It will return records in the ascending order of column! and descending order of eolumn2 Grouping Result It is used to arrange identical date Into groups so that aggregate functions can work on them Group by clause Itallows you to group two or more columns and then you can perform aggregate function on them Having clause Having clauses used to put concitions on groups satis Altering Table These commands allow you to change the structure ofthe table To Add New Column itil adel @ new column in your table To Modify Old Column It will update the date type or sizeof old column Alter Table ] To Change Name of Column ntps:www-codewihharry.comblogpostinysql-cheatsheet! m3 11225, 9:49AM Dropping Table MySQL Cheatshest | CodewnhHary DROP command [twill delete the complete table from the ® database MySQL Functions: ‘There are many functions in MyS0l that perform some task or operation and rtuin a single value Text/String Functions Text function work on strings Char Function Ieretuns the character for each integer passed Concat Function Iteoncatenates two strings elect Concat("“Harry", "Bhai" Lower/icase Itconverts @ string inte lowercase Upper/Ucase Iteonverts a string into uppercase Y cuhetr ntps:www-codewihharry.comblogpostinysql-cheatsheet! ans 11225, 9:49AM MySQL Cheatshest | CodewnhHary Trim It removes leading and traling spaces from a given string Select Trim(leading ' * FROM * Harry Bhai Instr It searches for given second string into the given fist sting Length It returns the length of given string in bytes elect Length(string Numeric Functions Numeric function works on numerical data and returns single output MoD Ieretuens modulus of two numbers Power Itreturns the number m raised to the nth power Round Itretums @ number rounded off number elect Round(415.193,1) Sqrt Ie returns the square root of a given number Select sqrt(1s) Truncate It returns @ number with some digits truncated ntps:www-codewihharry.comblogpostinysql-cheatsheet! ons 11225, 9:49AM MySQL Cheatshest | CodewnhHary Curdate Function Itreturns the current date Date Function Itextracts the date part of the expression Month Function Ieretums the month from the date passed elect Month(date Day Function Itreturns the day patt of a date elect Oay(date) Year Function Itreturns the year part of a date Now Function Ierotuns the current date and time sysdate Function It returns the time at which function executes elect sysdate() Aggregate Functions Aggregate functions or multiple row functions work on multiple data and returns a single result AVG Function Itealeulates the average of given data ntps:www-codewihharry.comblogpostinysql-cheatsheet! sons 11225, 9:49AM MySQL Cheatshest | CodewnhHary MAX Function Itretums the maximum value from a given column elect Max( MIN Function It returns the minimum value trom a given column Alias N f ble_name> SUM Function Itreturns the sum of values in given column MySQL Joins Jon clause is used te combine or merge rows rom two or more tables based on arelated atribute INNER JOIN It returns all rows trom multiple tables where the join condition is satisfied, tis the most common type of jon. LEFT OUTER JOIN It returns all rows trom the left-hand table specified in the ON condition and only thos the join condition is fulfiled rows rom the other table where R] 301N table2 ON tableL.column = table2.colum RIGHT OUTER JOIN It returns all rows from the RIGHT-hand table specified in the ON condition and only those rows fram the other table ‘where the join condition is satstied Je1 RIGHT [OUTER] 0IN FULL JOIN It combines the results of both eft and right outer joins SELECT con 1 FULL OUTER JOIN table2 ON tabled.colunn_nane = tal ame WHERE ci ntps:www-codewihharry.comblogpostinysql-cheatsheet! ss 11225, 9:49AM MySQL Cheatshest | CodewnhHary Download this Cheatsheet Add anew comment Type Your comment ‘Comments (37) © corarrominta mean © swtimsnas02gm 200 (ortsemead a eae @ © wameoveen_am se ‘can you ple upload videos for S01 or bettor understanding? Thank you © scvsce781-gm sntoos {AL good cheotsheet bhai but the long querys are not fly print when \we dex on downioad te cheatshaet Be JOIN QUERYS NA LAST Inona rns v Th ate use Google ere nt AAS ureters hse I a yy ep ese an money. ntps:www-codewihharry.comblogpostinysql-cheatsheet! rans 11225, 9:49AM MySQL Cheatshest | CodewnhHary Y codewithtary Copyright ©2025 Codoweninycom #¥@0 ntps:www-codewihharry.comblogpostinysql-cheatsheet! 1383

You might also like