Hw3zs
Hw3zs

Reputation: 7

Finding unique values in table

I need to find 240 unique values in my table which contains 300.000 rows.

my unique values are like:
elephant,turtle,bird,turkey,snake
(I have list all of them)

I have tried:

Where column_name like 'snake'
    or column_name like 'bird'
    or column name like 'snake' etc...

but I'm not sure it is a good way to find my values.

Upvotes: 0

Views: 210

Answers (2)

Maxime C.
Maxime C.

Reputation: 35

If you want to find the row with the values from a list you can do

SELECT * FROM animals WHERE name IN ('elephant','cat');

Upvotes: 1

Pablo Santa Cruz
Pablo Santa Cruz

Reputation: 181280

Try this:

> select distinct animal_name from your_300000_table;

So, suppose your table is this:

> create table animals (
    animal_id numeric(10) primary key,
    animal_type varchar(32) not null, -- here you have snake, bird, you name it
    added_date datetime2,
    location_lat numeric(11,8),
    location_lon numeric(11,8)
  );
> select distinct animal_type from animals;
> -- this will yield the expected result.

    

Upvotes: 1

Related Questions