Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,151,947 members, 7,814,213 topics. Date: Wednesday, 01 May 2024 at 09:07 AM

Please Help Me Out With Mysql Distinct - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Please Help Me Out With Mysql Distinct (691 Views)

Problem With Mysql, Phpmyadmin. Pls Help / Help Connecting Php With Mysql / Building Dynamic Websites With MySQL And PHP (2) (3) (4)

(1) (Reply) (Go Down)

Please Help Me Out With Mysql Distinct by deco2come: 3:31pm On Jul 22, 2011
I want to get all the values within a distinct value

[table]
[tr]
[td]username[/td][td]password[/td][td]gender[/td][td]age[/td][td]country[/td]

[/tr]
[/table]

$sql = "SELECT DISTINCT username FROM table LIMIT 10";

When I run this query, it select only the username without select the user's password, gender, age, and country. How can I make it select all the values within the username DISTINCT
Re: Please Help Me Out With Mysql Distinct by manutayo(m): 3:46pm On Jul 22, 2011
You can use the sql below.

SELECT DISTINCT
TOP (10)
UserName, Pasword, Gender, Age, Country
FROM TAbleName
Re: Please Help Me Out With Mysql Distinct by deco2come: 4:11pm On Jul 22, 2011
manutayo:

You can use the sql below.

SELECT DISTINCT
TOP (10)
UserName, Pasword, Gender, Age, Country
FROM TAbleName

Thanks for your reply. I tried the sql query but it doesn't work. Any other suggestion? Thank you
Re: Please Help Me Out With Mysql Distinct by manutayo(m): 5:14pm On Jul 22, 2011
ok, give me the name of the table you are trying to querry, also are u sure you have those colunm in the table?
Re: Please Help Me Out With Mysql Distinct by sayhi2ay(m): 2:05pm On Jul 23, 2011
use distinct on the username, and pull other columns.
Re: Please Help Me Out With Mysql Distinct by deco2come: 3:00pm On Jul 23, 2011
manutayo:

ok, give me the name of the table you are trying to querry, also are u sure you have those colunm in the table?

Thank you. The table name is
States
colums are

state_population, state_weather, major_income, historical_value.

I used DISTINCT state_population, how can I pull other inform that is associated with each population

sayhi2ay:

use distinct on the username, and pull other columns.


Can you use an example. Please include both the sql query. Thank you.
Re: Please Help Me Out With Mysql Distinct by sayhi2ay(m): 3:14pm On Jul 23, 2011
select distinct state_population, state_weather, income from etc etc.


distinct will apply only to the state_population column

(1) (Reply)

Venture Capitalist. / Moderators Wanted In A Fast Growing Forum. / How do I get joomla chart extension

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 46
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.