Questions tagged [unique]

Refers to an element that is distinctly different from any other element in a collection.

Refers to an element that is distinctly different from any other element in a collection.

6072 questions
81
votes
8 answers

Merge two arrays containing objects and remove duplicate values

I need to merge two arrays of objects into 1 array and remove duplicate email values. How can I do that? These are my sample arrays: $array1 = [ (object) ["email" => "gffggfg"], (object) ["email" => "wefwef@test.it"], (object) ["email"…
itsme
  • 48,972
  • 96
  • 224
  • 345
70
votes
5 answers

Firebase: how to generate a unique numeric ID for key?

I need numeric IDs for human readability. How do I get it in Firebase? I want numeric ID for keys, e.g. "000000001", "000000002","00000003","00000004". The reason I need it is because these IDs will become the permanent object ID both online and…
Ivan Wang
  • 8,306
  • 14
  • 44
  • 56
68
votes
4 answers

Does a name attribute have to be unique in a HTML document?

I remember reading in the spec once that both the id attribute and the name attribute share the same namespace and have to be unique. Henceforth I've always tried to fulfill this requirement in my applications, dreading even to give the same id and…
Vilx-
  • 104,512
  • 87
  • 279
  • 422
68
votes
19 answers

Javascript array sort and unique

I have a JavaScript array like this: var myData=['237','124','255','124','366','255']; I need the array elements to be unique and sorted: myData[0]='124'; myData[1]='237'; myData[2]='255'; myData[3]='366'; Even though the members of array look…
theHack
  • 1,938
  • 9
  • 26
  • 33
64
votes
3 answers

Select unique values with 'select' function in 'dplyr' library

Is it possible to select all unique values from a column of a data.frame using select function in dplyr library? Something like "SELECT DISTINCT field1 FROM table1" in SQL notation. Thanks!
nodm
  • 793
  • 1
  • 6
  • 8
63
votes
23 answers

Laravel check for unique rule without itself in update

I am having my validation rules for unique in the update section. In inserting or adding the unique rule is 'Email' => array('unique:driver_details'), and it will check for the unique coloumn. But this fails for the update section. While updating…
user3388086
61
votes
10 answers

Push only unique values into an array while looping

I am using the following loop to add items to an an array. I would like to know if it is somehow possible to not add $value to the $liste array if the value is already in the array? $liste = array(); foreach($something as $value){ …
Marc
  • 9,217
  • 21
  • 67
  • 90
58
votes
2 answers

Count number of times a date occurs and make a graph out of it

I have a list of dates, each date in it can occur more than once. I want to count the number of times each date occurs (histogram) and display it in a graph (with the Y axis being the number of times the date occurs and the X axis being the date…
SystemX17
  • 3,637
  • 4
  • 25
  • 36
57
votes
2 answers

Are UNIQUE indices case sensitive in MySQL?

Are indices (indexes) defined as UNIQUE case sensitive in MySQL?
nickf
  • 537,072
  • 198
  • 649
  • 721
57
votes
22 answers

How would you make a unique filename by adding a number?

I would like to create a method which takes either a filename as a string or a FileInfo and adds an incremented number to the filename if the file exists. But can't quite wrap my head around how to do this in a good way. For example, if I have this…
Svish
  • 152,914
  • 173
  • 462
  • 620
55
votes
3 answers

MySQL: unique field needs to be an index?

I have one UNIQUE field in my table, and I need to search over it quickly. Do I need to index it? Do searches over unique fields and indexed fields vary in speed or resource usage?
TomSawyer
  • 3,711
  • 6
  • 44
  • 79
55
votes
4 answers

phpMyAdmin Removing an index

I have a column in one of my tables which has been assigned an index. It is preventing me from having two of the same ID number. I am assuming the reason it is not letting me have two entries of the same ID is because it has been set to be…
Samuel Meddows
  • 36,162
  • 12
  • 38
  • 36
55
votes
12 answers

vba: get unique values from array

Is there any built-in functionality in vba to get unique values from a one-dimensional array? What about just getting rid of duplicates? If not, then how would I get the unique values from an array?
Alex Gordon
  • 57,446
  • 287
  • 670
  • 1,062
53
votes
2 answers

row_number() Group by?

I have a data set that contains the columns Date, Cat, and QTY. What I want to do is add a unique column that only counts unique Cat values when it does the row count. This is what I want my result set to look like: By using the SQL query below,…
user1582928
  • 535
  • 1
  • 5
  • 5
52
votes
7 answers

Subset with unique cases, based on multiple columns

I'd like to subset a dataframe to include only rows that have unique combinations of three columns. My situation is similar to the one presented in this question, but I'd like to preserve the other columns in my data as well. Here's my example: >…
bosbmgatl
  • 928
  • 3
  • 9
  • 12