Sorting Varchar Field Numerically in MySQL

Ankith Reddy
Updated on 30-Jul-2019 22:30:23

2K+ Views

‘LPAD(lower(column_name))’ is used to sort the varchar field numerically in MySQL. Let us see an example. Firstly, we will create a table. The CREATE command is used to create a table. mysql> create table SortingvarcharDemo -> ( -> List varchar(10) -> ); Query OK, 0 rows affected (0.82 sec) Records are inserted with the help of INSERT command. mysql> insert into SortingvarcharDemo values("99"); Query OK, 1 row affected (0.12 sec) mysql> insert into SortingvarcharDemo values("9"); Query OK, 1 row affected (0.17 sec) mysql> insert into SortingvarcharDemo ... Read More

Differences Between Class and Structure in C#

Samual Sam
Updated on 30-Jul-2019 22:30:23

203 Views

Structure In C#, a structure is a value type data type. It helps you to make a single variable hold related data of various data types. The struct keyword is used for creating a structure. To define a structure, you must use the struct statement. The struct statement defines a new data type, with more than one member for your program. Classes When you define a class, you define a blueprint for a data type. A class definition starts with the keyword class followed by the class name, and the class body enclosed by a pair of curly braces. Structure ... Read More

Usage of Backtick in SQL Statements

George John
Updated on 30-Jul-2019 22:30:23

502 Views

The backtick can be used in MySQL. To create a table, we can put table_name in backticks. Example of Backtick in MySQL. The CREATE command is used to create a table. Here, we have added the table name using the backtick symbol. mysql> create table `backtickSymbol` -> ( -> uniId int -> ); Query OK, 0 rows affected (1.65 sec) Records are inserted with the help of INSERT command. mysql> insert into `backtickSymbol` values(1); Query OK, 1 row affected (0.20 sec) mysql> insert into `backtickSymbol` values(2); Query ... Read More

Find Rows with Same Value in a Column in MySQL

Arjun Thakur
Updated on 30-Jul-2019 22:30:23

3K+ Views

First, we will create a table and insert some values into the table. Let us create a table. mysql> create table RowValueDemo -> ( -> Name varchar(100) -> ); Query OK, 0 rows affected (0.69 sec) Insert records using the insert command. We have added duplicate values as well for our example. mysql> insert into RowValueDemo values('John'); Query OK, 1 row affected (0.14 sec) mysql> insert into RowValueDemo values('Bob'); Query OK, 1 row affected (0.14 sec) mysql> insert into RowValueDemo values('Carol'); Query OK, 1 row affected ... Read More

Sort List of Dictionaries by Values in Python

Samual Sam
Updated on 30-Jul-2019 22:30:23

229 Views

Here one dictionary is given, our task is to sort by their values. Two values are present in this dictionary one is name and another is roll. First we display sorted list by their roll using lambda function and in-built sorted function. Second we display sorted list by the name and roll and third by their name. Example code Live Demo # Initializing list of dictionaries my_list1 = [{ "name" : "Adwaita", "roll" : 100}, { "name" : "Aadrika", "roll" : 234 }, { "name" : "Sakya" , "roll" : 23 }] print ("The list is sorted ... Read More

MySQL ON vs USING Clauses

Chandu yadav
Updated on 30-Jul-2019 22:30:23

6K+ Views

In general, we use ON in MySQL. In Joins, we use ON in a set of columns. USING is useful when both the tables share a column of the exact same name on which they join. Example of On. Creating our first table. mysql> CREATE table ForeignTableDemo -> ( -> Id int, -> Name varchar(100), - > FK int - > ); Query OK, 0 rows affected (0.47 sec) Creating our second table. mysql> CREATE table PrimaryTableDemo - > ... Read More

MySQL JDBC Driver Connection String

Chandu yadav
Updated on 30-Jul-2019 22:30:23

493 Views

The MySQL JDBC connection string look like this − Class.forName("com.mysql.jdbc.Driver"); Above, Driver is an interface. Whenever your JDBC is running outside an application server, then the class DriverManager establish the connection. The DriverManager class is as follows − conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/yourdatabaseName",”yourRootName","yourPassword"); Now, I am applying the above connection string to connect Java to MySQL database. The code is as follows. The following is the output that shows that MySQL connection with Java is successful.

Use MySQL JOIN Without ON Condition

Arjun Thakur
Updated on 30-Jul-2019 22:30:23

4K+ Views

We can use ‘cross join’ without on condition. Cross join gives the result in cartesian product form. For instance, if in one table there are 3 records and another table has 2 records, then the first record will match with all the second table records. Then, the same process will be repeated for second record and so on. Example of cross join Creating the first table mysql> CREATE table ForeignTableDemo - > ( - > Id int, - > Name varchar(100), - > FK int ... Read More

Plotting Solar Image in Python

Samual Sam
Updated on 30-Jul-2019 22:30:23

360 Views

In Python provides SunPy package for create solar image. In this package has different files which are solar data of proton/electron fluxes from various solar observatory and solar labs. Using pip install sunpy command, we can install sunpy package. Here we plot a sample AIA image. AIA is Atmospheric Imaging Assembly. This is another instrument board of the SDO. Here we use sunpy.Map() function to create a map from one of the supported data products. Example code import sunpy.map import matplotlib.pyplot as plt import sunpy.data.sample my_aia = sunpy.map.Map(sunpy.data.sample.AIA_171_IMAGE) fig = plt.figure() ax = plt.subplot(111, projection=my_aia) my_aia.plot() my_aia.draw_limb() ... Read More

Birthday Reminder Application in Python

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

808 Views

In this section we will see how to create a birthday reminder application using Python. Problem Statement Create an application using Python, which can check whether there is any birthday on the current day or not. If it is the birthday of some listed person, send a notification to the System with the name of that person. We need a file, where we can store the date and month and the name of the person as a lookup file for this application. The file will look like this − Here we will convert this application to a start-up application ... Read More

Advertisements