Chandu yadav has Published 1163 Articles

How to map keys to values for an individual field in a MySQL select query?

Chandu yadav

Chandu yadav

Updated on 30-Jun-2020 07:22:47

2K+ Views

You can use CASE statement in MySQL to map keys to values for an individual field in select query. The syntax is as follows −SELECT yourColumnName1, yourColumnName2, yourColumnName3, .........N (    CASE WHEN yourColumnName = 1 THEN 'ENABLED'    ELSE 'DISABLED'    END ) AS anyVariableName FROM yourTableName;You can use ... Read More

Is `definer` required when creating a MySQL stored procedure?

Chandu yadav

Chandu yadav

Updated on 30-Jun-2020 07:08:41

1K+ Views

No, definer part is not compulsory when you are creating a stored procedure. It is used when you want to create a definer.Check all the user and host from the MySQL.user table −mysql> select user, host from mysql.user;The following is the output −+------------------+-----------+ | user           ... Read More

MySQL BETWEEN without the beginning and endpoints?

Chandu yadav

Chandu yadav

Updated on 30-Jun-2020 06:56:34

49 Views

If you do not want to include start and end value in between, then use the following syntax −SELECT * FROM yourTableName WHERE yourColumnName BETWEEN yourStartingValue and yourEndingValue and    yourColumnName not in (yourStartingValue , yourEndingValue );To understand the above syntax, let us create a table. The query to create ... Read More

Insert sequential number in MySQL?

Chandu yadav

Chandu yadav

Updated on 30-Jun-2020 06:49:28

848 Views

You can insert sequential number in MySQL using session variable. The syntax is as follows −SELECT @anyVariableName − = anyIntegerValue; UPDATE yourTableName SET yourColumnName = @anyVariableName − = @anyVariableName+IncrementStep;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table ... Read More

How to add static value while INSERT INTO with SELECT in a MySQL query?

Chandu yadav

Chandu yadav

Updated on 30-Jun-2020 06:47:02

12K+ Views

You can add static value when you use INSERT INTO SELECT MySQL query. Write the value directly in the select statement or you can add with the help of variable which initializes the value.Case 1 − Place the value directly in the INSERT INTO SELECT statement. The syntax is as ... Read More

How to Insert custom date into MySQL timestamp field?

Chandu yadav

Chandu yadav

Updated on 30-Jun-2020 06:43:11

2K+ Views

The problem with UNIX_TIMESTAMP() function is that it returns an integer while we want to insert custom date i.e. not any integer part to MySQL date.Do not use UNIX_TIMESTAMP() for your column defined as TIMESTAMP because UNIX_TIMESTAMP() returns an integer.Check the UNIX_TIMESTAMP. The query is as follows −mysql> select UNIX_TIMESTAMP( ... Read More

MySQL Order By specific strings?

Chandu yadav

Chandu yadav

Updated on 30-Jun-2020 06:33:31

278 Views

Order by the choice of strings you want, using the FIELD() function. The syntax is as follows −SELECT *FROM yourTableName ORDER BY FIELD(yourColumnName, ’yourValue1’, ’yourValue2’, ’yourValue3’, ....N);To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table OrderByListOfStrings   ... Read More

Iterate through a LinkedList using an Iterator in Java

Chandu yadav

Chandu yadav

Updated on 29-Jun-2020 13:53:57

6K+ Views

An Iterator can be used to loop through an LinkedList. The method hasNext( ) returns true if there are more elements in LinkedList and false otherwise. The method next( ) returns the next element in the LinkedList and throws the exception NoSuchElementException if there is no next element.A program that ... Read More

Remove a specific element from a LinkedList in Java

Chandu yadav

Chandu yadav

Updated on 29-Jun-2020 13:51:29

4K+ Views

A specific element in the LinkedList can be removed using the java.util.LinkedList.remove() method. This method removes the specified element the first time it occurs in the LinkedList and if the element is not in the LinkedList then no change occurs. The parameter required for the LinkedList.remove() method is the element ... Read More

Remove an element from an ArrayList using the ListIterator in Java

Chandu yadav

Chandu yadav

Updated on 29-Jun-2020 13:48:11

781 Views

An element can be removed from an ArrayList using the ListIterator method remove(). This method removes the current element in the ArrayList. If the remove() method is not preceded by the next() method, then the exception IllegalStateException is thrown.A program that demonstrates this is given as follows.Example Live Demoimport java.util.ArrayList; import ... Read More

Previous 1 ... 5 6 7 8 9 ... 117 Next
Advertisements