Do you know about the SLICING technique that helps you work around strings in Python??
To handle sub-strings, you can use the SLICING method.
ππ
Let's say we have a string.
a = "This is a string."
You can slice between the string!
π a[start_index : end_index : stride]
Terms:-
start_index -> Takes an integer value; this is the index value (inclusive) from where you want to start slicing.
end_index -> Takes an integer value; this is the index value (exclusive) where you want the slicing to end.
stride -> Takes an integer value; indicates how many characters to skip after the first character is retrieved.
Note: The first character index is always 0.
Taking the same string, a = "This is a string.", here are a few examples:-
1. Print "is a" from the string
-> a[5 : 9]
2. Print the entire string by skipping 2 characters
-> a[: : 2]
O/P: 'Ti sasrn.'
An explanation for the 2nd example:-
When we don't mention the start_index and end_index, slicing automatically starts from the first character at index 0 and continues till the end of the string.
Note that: We have to provide at least one value for slicing to occur.
3. End the slicing at index 9 and move characters by 2
-> a[: 10 : 2]
Since we want to include the 9th index, we end slicing at the 10th index, as the 10th index is not included.
π NEGATIVE INDEXING 4. Print the string backwards
-> a[: : -1]
O/P: '.gnirts a si sihT'
An explanation for the 4th example:-
When stride is -1, the string moves backwards from the end.
5. What would be the output of a[-7 : -2] ??
The last character is at index -1.
An explanation for 5th example:-
So, at -7, we have the 's' from 'strings', and the string would end at -2, where 'n' is present.
-2 is inclusive because the starting index from the end is -1.
Therefore, the output is: 'strin'
β’ β’ β’
Missing some Tweet in this thread? You can try to
force a refresh
The topic of TRIGGERS is a level-up from creating queries and sub-queries in the handling databases.
A super-easy guide to triggers in SQL π§΅π
βοΈ What is a trigger in the laymen (standard) language?
When someone pokes you or does something to agitate you, there is a high chance that you might get 'triggered' automatically! Right?
βοΈ Triggers in SQL
So, when we say TRIGGERS in SQL, it is simply a stored program that gets executed on its own when a triggering event occurs. Now, triggers are a part of PL/SQL.
PL/SQL is an extension of SQL where SQL queries are used and procedural statements/language.
A Beginner-friendly version of SQL (UPDATE and DELETE)
π§΅π
π Let's look at the table first!
The name of the table is -> faculties
We have columns as FacultyId, Name, Class, EmailId and Salary.
βοΈ UPDATE
This clause is used to change values in a specified column.
You may or may not provide a condition along with the change you want to make.
π Update without condition:-
UPDATE table_name SET column_name = column_value;
SQL - A Beginner-friendly version! π
(Clauses: IN, BETWEEN and LIKE)
Thread π§΅
πWhich table are we working on today?
The name of the table is "products". So the columns that we have are productCode, productName, productDescription, among others.
Take a look π
βοΈ IN
This clause would reduce the efforts to write multiple OR conditions. It helps you find a specific match for a value.
π select column1, column2 from table_name where EXPRESSION IN ('value1', 'value2')
Here is another thread of the most important clauses to boost your SQL queries to the next level!
Advance SQL, A beginner-friendly version! (#DataScience)
Thread π§΅
Let me explain what the table looks like.
The table name is customer_list, where the columns are ID, name, address, zip code, phone, city, country, notes & SID.
See the image for reference
βοΈ GROUP BY
This clause is used to group rows that have the same values together. It summarises data from the database.
Note: The group by clause returns one row for each group.
π Query: select col_name from table_name GROUP BY column_name;