How to avoid duplicate values in mysql? -


i have table 'table1' this:

id    org_id  project_name project_id emp_id business_id         first_name  from_date  3862    62      'project1'    51       2          73             'employee1' '2015-01-01' 3864    62      'project2'    52       3          74             'employee2' '2015-03-18' 3866    62      'project2'    52       2          74             'employee1' '2015-06-22' 

i want unique employees. output should this:

id    org_id  project_name project_id emp_id business_id         first_name  from_date  3862    62      'project1'    51       2          73             'employee1' '2015-01-01' 3864    62      'project2'    52       3          74             'employee2' '2015-03-18' 

any help!!

it's easy do.

id org_id project_name project_id emp_id business_id

when you're creating table put unique constraint @ end of values want unique/not duplicated.

create table table1 ( id int not null, org_id int not null, project_name varchar(255) not null unique, project_id int not null unique, emp_id int not null unique, business_id int not null unique, first_name varchar(255) not null unique, from_date datetime not null, ) 

hope helps!

edit: if want entered information unique just:

select * table1 

then loop thought values recieved , check if values project_name, project_id, emp_id, business_id or first_name same 1 of given values. 1 of values not unique.


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -