Select Duplicate Records from Database and Display Count in MySQL

Smita Kapse
Updated on 30-Jul-2019 22:30:25

405 Views

To select only duplicate records from database and display the count, use HAVING along with aggregate function count(). Let us first create a table −mysql> create table duplicateRecords    -> (    -> ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> ClientName varchar(20)    -> ); Query OK, 0 rows affected (0.49 sec)Following is the query to insert records in the table using insert command −mysql> insert into duplicateRecords(ClientName) values('John'); Query OK, 1 row affected (0.16 sec) mysql> insert into duplicateRecords(ClientName) values('Carol'); Query OK, 1 row affected (0.17 sec) mysql> insert into duplicateRecords(ClientName) values('John'); Query OK, 1 row affected ... Read More

Check If Field Exists and Return Result Set in MySQL

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

348 Views

To check if field exists and then to return the result set, you can use the below syntax −show columns from yourTableName where field='yourColumnName';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,    UserAddress varchar(200),    UserCountryName varchar(20) ); Query OK, 0 rows affected (0.67 sec)Here is the query to check if field exists and then return the result set −mysql> show columns from DemoTable where field='UserCountryName';This will produce the following output −+-----------------+-------------+------+-----+---------+-------+ | Field           | ... Read More

Assess Compatibility of 27128-20 with 8085AH-2 in 8085 Microprocessor

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

81 Views

The 8085AH-2 always works with a clock period of 200nS. We start the calculations by assuming that the valid address, and IO/M* signals are sent by the 8085AH-2 time 0 nS. After that the, Arithmetic Logical Unit moves to state 0 at 50 nS (tAL), and RD* gets activated at 115 nS (tAC).Earliest data output time considering tAcc: Address ranging from A13 to A18 is received by 27128 from 8085 processor by means of the octal line driver 74LS244 at 12 ns of time. Address ranging from A7 to A0 is received by the 27128 from 8085 processor by means of 74LS373. So ... Read More

Remove ON UPDATE CURRENT_TIMESTAMP from MySQL Column

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

5K+ Views

The ON UPDATE CURRENT_TIMESTAMP defines that an update without an explicit timestamp would result in an update to the current timestamp value.You can remove ON UPDATE CURRENT_TIMESTAMP from a column using ALTER command.The syntax is as followsALTER TABLE yourTableName CHANGE yourTimeStampColumnName yourTimeStampColumnName timestamp NOT NULL default CURRENT_TIMESTAMP;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table removeOnUpdateCurrentTimeStampDemo    - > (    - > Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    - > Name varchar(20),    - > UserUpdateTimestamp timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP   ... Read More

Get Current Wi-Fi BSSID in Android

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

2K+ Views

This example demonstrate about How to get current Wi-Fi BSSID in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. In the above code, we have taken text view to show WIFI ID.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.accounts.Account; import android.accounts.AccountManager; import android.app.ActivityManager; import android.bluetooth.BluetoothManager; import android.content.Context; import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbManager; import android.net.ConnectivityManager; import android.net.Network; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Build; import android.os.Bundle; import android.os.PowerManager; ... Read More

LocalDateTime withDayOfYear Method

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

76 Views

An immutable copy of a LocalDateTime with the day of year altered as required is done using the method withDayOfYear() in the LocalDateTime class in Java. This method requires a single parameter i.e. the day of year that is to be set in the LocalDateTime and it returns the LocalDateTime with the day of year altered as required.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main {    public static void main(String[] args) {       LocalDateTime ldt1 = LocalDateTime.parse("2019-02-18T23:15:30");       System.out.println("The LocalDateTime is: " + ldt1);       LocalDateTime ... Read More

Collection Find Always Returns All Fields with MongoDB

Anvi Jain
Updated on 30-Jul-2019 22:30:25

581 Views

You can return a specific field from collection.find() by using the following syntax.Case 1 − The syntax is as follows −db.yourCollectionName.find({}, {"yourFieldName":1}).pretty();The above field name is set to 1 means it will return only that field. If you set to 0 it will return all fields except the field which is set to 0.Case 2 − The syntax is as follows −db.yourCollectionName.find({}, {"yourFieldName":0}).pretty();To understand the above syntaxes, let us create a collection with document. The query to create a collection with document is as follows −> db.returnFieldInFindDemo.insertOne({"StudentName":"John", "StudentAge":23, "TechnicalSubject":["MongoDB", "MySQL"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8ebfe72f684a30fbdfd566") } ... Read More

C++ Program to Implement Queue

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

3K+ Views

QueueThe queue which is implemented as FIFO where insertions are done at one end (rear) and deletions are done from another end (front). The first element that entered is deleted first.Queue operations are −EnQueue (int data) − Insertion at rear endint DeQueue()− Deletion from front endThis is a C++ program to implement queue using array.AlgorithmBegin    function Enqueue() to insert elements in queue:       If queue is completely filled up then print “Overflow”.       Otherwise insert element at rear.       Update the value of rear End Begin    function Dequeue() to delete elements from ... Read More

Make Custom Dialog with Rounded Corners in Android

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

6K+ Views

This example demonstrate about How to make custom dialog with rounded corners in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     In the above code, we have taken button. When user click on button, it will show custom dialog.Step 3 − Add the following code to src/MainActivity.javapackage com.example.andy.myapplication; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; public class MainActivity extends ... Read More

Compare Timestamps in MySQL

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

4K+ Views

To compare timestamps in MySQL, you can use DATE(). Let us first create a table−mysql> create table comparingTimestampDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> AdmissionDate timestamp    -> ); Query OK, 0 rows affected (0.54 sec)Following is the query to insert records in the table using insert command −mysql> insert into comparingTimestampDemo(AdmissionDate) values('2019-03-31'); Query OK, 1 row affected (0.13 sec) mysql> insert into comparingTimestampDemo(AdmissionDate) values('2019-04-10'); Query OK, 1 row affected (0.12 sec) mysql> insert into comparingTimestampDemo(AdmissionDate) values('2019-04-15'); Query OK, 1 row affected (0.17 sec) mysql> insert into comparingTimestampDemo(AdmissionDate) values('2019-03-29'); Query OK, 1 ... Read More

Advertisements