What is SQL Regex in Hindi?

Regular Expression को हम RegEx फंक्शन भी कहते है इसका उपयोग characters के विभिन्न sequences को patterns से match करने के लिए किया जाता है।
RegEx फंक्शन बहुत सारे अलग अलग data type integer, special characters, Strings, आदि का combination हो सकता है। डेटाबेस से डाटा के एक छोटे subset को खोजने के लिए हम Regex फंक्शन का उपयोग करते है।

PatternDescription
*Matches zero or more instances of the preceding String
+Matches one or more instances of the preceding String
.Matches any single character
?Matches zero or one instance of the preceding Strings
^^ matches the beginning of a String
$$ matches the ending of a String
[abc]Matches any character listed in between the square brackets
[^abc]Matches any character not listed in between the square brackets
[A-Z]Matches any letter in uppercase
[a-z]Matches any letter in lowercase
[0-9]Matches any digit between 0-9
[[:<:]]Matches the beginning of words
[[:>:]]Matches the end of words
[:class:]Matches any character class
p1|p2|p3Mathes any of the specified pattern
{n}Matches n instances of the preceding element
{m,n}Matches m through n instances of the preceding element

Syntax for using SQL Regex

SELECT statements… WHERE field_name REGEXP 'my_pattern';

Example : Student Table

Student_IDNameEmail_idCourse_idCourse_name
1001AmitAmit2525@gmail.com1234Python
1002SachinSachin2867@gmail.com1235C++
1003DivyaDiv395@yahoo.com1234Python
1004Shivanishivani9685@gmail.com1238Sql
1005AnupAnup1265@yahoo.com1238Sql
1006AbhishekAbhi4265@hotmail.com1236java

Query1 : Student table से किसी specified String को match करना।

select * from student where course_name regexp 'python';
OUTPUT
1001  Amit   Amit2525@gmail.com  1234   Python
1003  Divya  Div395@yahoo.com    1234   Python

Query 2 : Student table से ऐसे String को match करना। जिसकी ending @hotmail.com से हो। इसके लिए हम $ pattern का उपयोग करेंगे।

select * from student where email_id regexp '@hotmail.com$' ;
OUTPUT
1006  Abhishek  Abhi4265@hotmail.com  1236  java 

Query 3 : Student table के name कॉलम से ऐसे String को match करना। जिसमे कोई नाम Di से शुरू हो।

select * from student where name regexp 'di?';
OUTPUT
1003  Divya  Div395@yahoo.com    1234   Python