Smita Kapse has Published 558 Articles

Sort a MySQL table column value by part of its value?

Smita Kapse

Smita Kapse

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

97 Views

You can use ORDER BY RIGHT() for this. Let us first create a table −mysql> create table DemoTable    (    UserId varchar(100)    ); Query OK, 0 rows affected (0.33 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('User1234'); Query OK, 1 row affected ... Read More

How to query MongoDB a value with $lte and $in?

Smita Kapse

Smita Kapse

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

123 Views

Let us first create a collection with documents −> db.queryMongoValueDemo.insertOne(    {       _id:101,       "ScoreDetails":[{Score:80}, {Score:45}, {Score:25}, {Score:70}]    } ); { "acknowledged" : true, "insertedId" : 101 } > db.queryMongoValueDemo.insertOne(    {       _id:102,       "ScoreDetails":[{Score:80}, {Score:24}, {Score:34}]    } ... Read More

Java DatabaseMetaData getMaxColumnsInGroupBy() method with example.

Smita Kapse

Smita Kapse

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

18 Views

The getMaxColumnsInGroupBy() method of the DatabaseMetaData interface is used to find out the maximum number of columns that the underlying database allows in a GROUP BY clause.This method returns an integer value, representing the maximum number of columns allowed in a GROUP BY clause. If this value is 0 it ... Read More

How to display data from a MySQL column separated by comma?

Smita Kapse

Smita Kapse

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

514 Views

You can use GROUP_CONCAT() function from MySQL to display result as a comma separated list. Let us first create a table −mysql> create table DemoTable    (    Value int    ); Query OK, 0 rows affected (0.26 sec)Insert some records in the table using insert command −mysql> insert into ... Read More

Java DatabaseMetaData getMaxColumnsInTable() method with example.

Smita Kapse

Smita Kapse

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

28 Views

The getMaxColumnsInTable() method of the DatabaseMetaData interface is used to find out the maximum number of columns that the underlying database allows in a table.This method returns an integer value, representing the maximum number of columns allowed in a table. If this value is 0 it indicates that there is ... Read More

How to use CHAR_LENGTH() in MySQL CREATE TABLE query?

Smita Kapse

Smita Kapse

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

78 Views

Use CHAR_LENGTH(yourColumnName) at the time of table creation. Let us first see an example and create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Title varchar(200),    `Number_of_characters` int as (char_length(Title))    ); Query OK, 0 rows affected (0.18 sec)Insert some ... Read More

Counting common elements in MySQL?

Smita Kapse

Smita Kapse

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

340 Views

To count common elements, use COUNT() and GROUP BY. Let us first create a table −mysql> create table DemoTable    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Number int    ); Query OK, 0 rows affected (0.20 sec)Insert some records in the table using insert command −mysql> ... Read More

Java DatabaseMetaData getMaxStatements() method with example.

Smita Kapse

Smita Kapse

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

56 Views

The getMaxStatements() method of the DatabaseMetaData interface is used to find out the maximum number of open statements (objects) that the underlying database allows at one time.This method returns an integer value, representing the maximum number of statements that are allowed to be open at a time. If this value ... Read More

Lower case column names with MySQL SELECT?

Smita Kapse

Smita Kapse

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

670 Views

Let us first create a table −mysql> create table DemoTable    (    UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    UserFirstName varchar(20),    UserLastName varchar(20),    UserAge int,    UserCountryName varchar(20)    ); Query OK, 0 rows affected (0.27 sec)Now check the description of table.mysql> desc DemoTable;This will produce ... Read More

How can I avoid “repair with keycache” in MySQL?

Smita Kapse

Smita Kapse

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

273 Views

To avoid repair with keycache in MySQL, you need to follow the below syntax −create table yourNewTableName as (select *from yourOldTableName); alter table yourNewTableName add index(yourCoumnName);Let us first create a table −mysql> create table DemoTable    (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentFirstName varchar(20),    StudentLastName ... Read More

Advertisements