B
B
BitRouter2018-11-15 20:51:00
PHP
BitRouter, 2018-11-15 20:51:00

How to get only unique data from the database?

Tell me the format of the query to the database
there is a table (for example):

.     id    |  data_id  
-------------------------
      1     |     1
-------------------------
      2     |     1
-------------------------
      3     |     2
-------------------------
      4     |     1
-------------------------
      5     |     3

you need to get an array of MySQL / PostgreSQL databases at the output - it doesn’t matter .. Everything would be fine, but I don’t understand what question to ask the great Google)))
data_id = array(1,2,1,3);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
1
1001001, 2018-11-15
@BitRouter

select data_id from table where id <> data_id

R
Ruslan Fedoseev, 2018-11-15
@martin74ua

select distinct data_id from tablename;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question