Archive for category SQL

sql find duplicate record using fields

 

SELECT COUNT(id)
FROM  Employee
GROUP BY id
HAVING ( COUNT(id )>1 )

 

using two fields

SELECT
    name, email, COUNT(*)
FROM
    users
GROUP BY
    name, email
HAVING 
    COUNT(*) > 1

Leave a comment

SQL ADD,DROP COLUMN+ FK

DROP
ALTER TABLE ASSIGNMENT_DETAIL DROP COLUMN NEIGHBOURHOOD_ID;
ALTER TABLE ASSIGNMENT_DETAIL DROP COLUMN NEIGHBOURHOOD_STREET_ID;

ADD
ALTER TABLE ORGANIZATION_PERSON ADD ASSIGNMENT_ID NUMBER(38,0);
ALTER TABLE ORGANIZATION_PERSON ADD ASSIGNMENT_STATUS NUMBER(38,0);

ADD FK

ALTER TABLE ORGANIZATION_PERSON
ADD CONSTRAINT FK_Asignment_ID FOREIGN KEY (ASSIGNMENT_ID)
REFERENCES ASSIGNMENT_DETAIL(ID);

, , , ,

Leave a comment