Jump to content

Need help with DISTINCT


Jack.Straw

Recommended Posts

Hello.  How can i make the following statement fill the $row array with the PhoneNumer colum (which exists in the Friends table) as well? 

[code]
$result=mysql_query("SELECT DISTINCT Name FROM Friends WHERE Catagory='Female' ORDER BY Name ASC ");
while ($row=mysql_fetch_array($result))
  {
  echo $row[Name]." - ".$row[PhoneNumber];
  }
[/code]

$row[PhoneNumber] doesn't get filled. Can anyone help me understand why?
Link to comment
Share on other sites

[quote author=Jack.Straw link=topic=114650.msg468468#msg468468 date=1163615618]
I want to display phone numbers from rows that have distinct names..
[/quote]
I'm not sure I know what you mean by this... which phone number would you show if there were 3 matching rows?
Link to comment
Share on other sites

Ok, say the database looks like this:
[u]Name[/u] - [u]Phone[/u]
Joe - 333-3333
Dan - 444-4444
Bill - 444-4444
Joe - 666-6666
Tom - 777-7777

I want it to pick out distinct names and display the phone numers.  It would fill the array with:
Joe - 333-3333
Dan - 444-4444
Bill - 444-4444
Tom - 777-7777

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.