Select Last 10 Rows from MySQL

Chandu yadav
Updated on 12-Sep-2023 01:58:16

39K+ Views

To select last 10 rows from MySQL, we can use a subquery with SELECT statement and Limit concept. The following is an example. Creating a table. mysql> create table Last10RecordsDemo -> ( -> id int, -> name varchar(100) -> ); Query OK, 0 rows affected (0.75 sec) Inserting records into the table. mysql> insert into Last10RecordsDemo values(1, 'John'), (2, 'Carol'), (3, 'Bob'), (4, 'Sam'), (5, 'David'), (6, 'Taylor'); Query OK, 6 rows affected (0.12 sec) Records: 6 Duplicates: 0 Warnings: 0 mysql> insert into Last10RecordsDemo ... Read More

Get Correlation Between Two Columns in Pandas

Rishikesh Kumar Rishi
Updated on 12-Sep-2023 01:32:26

32K+ Views

We can use the .corr() method to get the correlation between two columns in Pandas. Let's take an example and see how to apply this method.StepsCreate a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.Print the input DataFrame, df.Initialize two variables, col1 and col2, and assign them the columns that you want to find the correlation of.Find the correlation between col1 and col2 by using df[col1].corr(df[col2]) and save the correlation value in a variable, corr.Print the correlation value, corr.Exampleimport pandas as pd df = pd.DataFrame(    {       "x": [5, 2, 7, 0],       "y": [4, ... Read More

Hide Axes and Gridlines in Matplotlib

Rishikesh Kumar Rishi
Updated on 12-Sep-2023 01:31:20

45K+ Views

To hide axes (X and Y) and gridlines, we can take the following steps −Create x and y points using numpy.Plot a horizontal line (y=0) for X-Axis, using the plot() method with linestyle, labels.Plot x and y points using the plot() method with linestyle, labels.To hide the grid, use plt.grid(False).To hide the axes, use plt.axis('off')To activate the labels' legend, use the legend() method.To display the figure, use the show() method.Exampleimport numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-10, 10, 50) y = np.sin(x) plt.axhline(y=0, c="green", linestyle="dashdot", label="y=0") plt.plot(x, y, c="red", lw=5, linestyle="dashdot", label="y=sin(x)") plt.grid(False) plt.axis('off') ... Read More

Add Rows to a Table Using JavaScript DOM

Saurabh Jaiswal
Updated on 12-Sep-2023 01:30:07

47K+ Views

We will learn how to add a row to a table using JavaScript dom. To achieve this, we have multiple methods. Some of them are the following. Using the insertRow() method By creating the new Element Using the insertRow() Method The inserRow() method is used to insert a new row at the starting of the table. It creates a new element and inserts it into the table. This takes a number as a parameter that specifies the position of the table. If we do not pass any parameter then it inserts the row at the starting of ... Read More

Difference Between Primary Key and Foreign Key in Database

Kiran Kumar Panigrahi
Updated on 12-Sep-2023 01:24:28

32K+ Views

In a relational database, keys are the most important elements to maintain the relationship between two tables or to uniquely identify the data from a table. Primary key is used to identify data uniquely therefore two rows can't have the same primary key. It can't be null. On the other hand, foreign key is used to maintain relationship between two tables. The primary key of a table acts as the foreign key in another table. The Foreign key in a table helps enforce Referential Integrity constraint. Read this tutorial to find out more about Primary and Foreign keys and how ... Read More

Advantages and Disadvantages of JavaScript

Abdul Rawoof
Updated on 12-Sep-2023 01:20:55

31K+ Views

JavaScript might be a client-side scripting language, inferring that the client's browser handles ASCII text file processing rather than an online server. With the aid of JavaScript, this can load the webpage without contacting the primary server. For instance, a JavaScript function might verify that all the required fields are filled out on an online form before it is submitted. The JavaScript code has the ability to output an error message before any data is actually sent to the server. Both advantages and disadvantages apply to JavaScript. A client's browser is frequently used to execute JavaScript directly. Similar advantages to ... Read More

Stop forEach Method in JavaScript

Shubham Vora
Updated on 12-Sep-2023 01:16:52

49K+ Views

In JavaScript, Programmers can use the forEach() method to iterate through the array of elements. We can call a callback function, which we can pass as a parameter of the forEach() method for every array element. Sometimes, we may require to stop the forEach() loop after executing the callback function for some elements. We can use the ‘break’ keyword with a normal loop to stop it, as shown below. for(let i = 0; i < length; i++){ // code if( some condition ){ break; } ... Read More

Remove or Hide X-axis Labels from Seaborn Matplotlib Plot

Rishikesh Kumar Rishi
Updated on 12-Sep-2023 01:10:01

40K+ Views

To remove or hide X-axis labels from a Seaborn / Matplotlib plot, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Use sns.set_style() to set an aesthetic style for the Seaborn plot.Load an example dataset from the online repository (requires Internet).To hide or remove X-axis labels, use set(xlabel=None).To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt import seaborn as sns plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True sns.set_style("whitegrid") tips = sns.load_dataset("tips") ax = sns.boxplot(x="day", y="total_bill", data=tips) ax.set(xlabel=None) plt.show()OutputRead More

Verify Element Presence or Visibility in Selenium WebDriver

Debomita Bhattacharjee
Updated on 12-Sep-2023 01:07:53

40K+ Views

We can verify whether an element is present or visible in a page with Selenium webdriver. To check the presence of an element, we can use the method – findElements.The method findElements returns a list of matching elements. Then, we have to use the method size to get the number of items in the list. If the size is 0, it means that this element is absent from the page.Syntaxint j = driver.findElements(By.id("txt")).size();To check the visibility of an element in a page, the method isDisplayed() is used. It returns a Boolean value( true is returned if the element is visible, ... Read More

Change Font Color of Text Using JavaScript

Shubham Vora
Updated on 12-Sep-2023 01:06:22

43K+ Views

This tutorial teaches us to change the font color of the text using JavaScript. While working with JavaScript and developing the frontend of the application, it needs to change the font color of the text using JavaScript when an event occurs. For example, we have an application which can turn on or off the device. We have a button to turn on or off the device. When the device is on, make the button text green. Otherwise, make the button text red. So, in such cases, programmers need to change the font color using JavaScript. We have some different method ... Read More

Advertisements