Chandu yadav has Published 1163 Articles

Select last 20 records ordered in ascending order in MySQL?

Chandu yadav

Chandu yadav

Updated on 30-Jul-2019 22:30:24

478 Views

To select last 20 records in ascending order, you can use subquery LIMIT clause. The syntax is as followsSELECT *FROM (    SELECT *FROM yourTableName ORDER BY yourColumnName desc limit 20 ) anyVariableName order by anyVariableName.yourColumnName;To understand the above syntax, let us create a table. The query to create a ... Read More

Difference between two selects in MySQL?

Chandu yadav

Chandu yadav

Updated on 30-Jul-2019 22:30:24

2K+ Views

You can use subqueries for difference between two selects in MySQL. The syntax is as follows:SELECT *FROM yourTableName where yourColumnName NOT IN(SELECT yourColumnName FROM youTableName WHERE yourCondition;To understand the above syntax, let us create a table. The query to create a table is as follows:mysql> create table DifferenceSelectDemo    -> ... Read More

Create a procedure in MySQL with parameters?

Chandu yadav

Chandu yadav

Updated on 30-Jul-2019 22:30:24

4K+ Views

You can create a parameter using IN and OUT. IN is used to take input parameter and OUT can be used for output.The syntax is as followsDELIMITER // CREATE PROCEDURE yourProcedureName(IN yourParameterName dataType, OUT yourParameterName dataType ) BEGIN yourStatement1; yourStatement2; . . N END; // DELIMITER ;First, ... Read More

How to find nth highest value of a MySQL column?

Chandu yadav

Chandu yadav

Updated on 30-Jul-2019 22:30:24

524 Views

To find the nth highest value of a column, you need to use ORDER BY DESC with LIMIT clause. If you want the second highest value of a column, use the below syntax:SELECT *FROM yourTableName ORDER BY DESC yourColumnName LIMIT 1, 1;If you want the fourth highest value of a ... Read More

Check if a string contains numbers in MySQL?

Chandu yadav

Chandu yadav

Updated on 30-Jul-2019 22:30:24

2K+ Views

To check a string contains numbers, you can use regexp i.e. Regular Expressions. The syntax is as follows −SELECT *FROM yourTableName where yourColumnName REGEXP ‘[0-9]’;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table StringContainsNumber    -> ( ... Read More

The ElementTree XML API in Python

Chandu yadav

Chandu yadav

Updated on 30-Jul-2019 22:30:24

10K+ Views

The Extensible Markup Language (XML) is a markup language much like HTML. It is a portable and it is useful for handling small to medium amounts of data without using any SQL database.Python's standard library contains xml package. This package has ElementTree module. This is a simple and lightweight XML ... Read More

How do you OR two MySQL LIKE statements?

Chandu yadav

Chandu yadav

Updated on 30-Jul-2019 22:30:24

66 Views

You can OR two like statements using the following syntax −SELECT *FROM yourTableName WHERE (yourColumnName like '%yourValue1%' OR yourColumnNamelike '%yourValue2%') AND yourColumnName = yourValue;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table ORLikeDemo    -> (   ... Read More

SHOW TABLE statement with multiple LIKE values in MySQL?

Chandu yadav

Chandu yadav

Updated on 30-Jul-2019 22:30:24

351 Views

You can use WHERE clause and OR operator to show table with multiple LIKE. The syntax is as follows:show table from yourDatabaseName where tables_in_yourDatabaseName Like ‘%anyTableName%’ or tables_in_yourDatabaseName Like ‘%anyTableName2%’ or tables_in_yourDatabaseName Like ‘%anyTableName3%’ . . . . or tables_in_yourDatabaseName Like ‘%anyTableNameN%’In the above syntax, only the table name in ... Read More

Low-level networking interface in Python (socket)

Chandu yadav

Chandu yadav

Updated on 30-Jul-2019 22:30:24

888 Views

The 'socket' module in Python's standard library defines how server and client machines can communicate using socket endpoints on top of the operating system. The 'socket' API contains functions for both connection-oriented and connectionless network protocols.Socket is an end-point of a two-way communication link. It is characterized by IP address ... Read More

How can I merge two MySQL tables?

Chandu yadav

Chandu yadav

Updated on 30-Jul-2019 22:30:24

4K+ Views

To merge two MySQL tables, use the following syntax −INSERT IGNORE INTO yourTableName1 select *from yourTableName2;We will create two tables with some records. After that the merge process will begin using the above syntax.Creating first table −mysql> create table MergeDemo1 -> ( -> id ... Read More

Advertisements