-6

I want to be able to fetch names from a table but distinctively (should only appear once)

Currently I'm getting: jules,ange,kapo,jules

// this is the query
$result= mysqli_query($db,"select names from uploadedproduct");
Sumit Wadhwa
  • 2,825
  • 1
  • 20
  • 34
Jules
  • 3
  • 3
  • Your question is very unclear. You say that you want to fetch the names once, but then you show a list with `jules` twice? – M. Eriksson Sep 24 '19 at 12:30
  • why is alot off code removed from the question with a edit? Also see [Why should I provide a Minimal Reproducible Example for a very simple SQL query?](https://meta.stackoverflow.com/questions/333952/why-should-i-provide-a-minimal-reproducible-example-for-a-very-simple-sql-query) – Raymond Nijland Sep 24 '19 at 12:34
  • man i want to view jules,ange,kapo only – Jules Sep 24 '19 at 12:55
  • yeah distinct has worked and thank you – Jules Sep 24 '19 at 13:06

1 Answers1

4

You need Distinct

$result = mysqli_query($db,"select DISTINCT names from uploadedproduct");

Distinct optimization allows to select only unique rows. The above query selects distinctively but case insensitive. For it be case sensitive, you could use BINARY opeartor:

$result = mysqli_query($db,"select DISTINCT (BINARY names) from uploadedproduct");
Sumit Wadhwa
  • 2,825
  • 1
  • 20
  • 34