Jump to content

Selecting DISTINCT question ...


iPixel

Recommended Posts

Ive got this table .. it contains first name, last name, address1, address2, city, state, zip, email, phone etc....

 

I want to write a query that will select everything from that table, but only unique addresses... so

if address

 

12-85 Jewel Ave

Fresh Meadows NY 11365

 

exists twice... only return the first record.

 

im running this ...

 

$query = "SELECT DISTINCT address1 FROM imgcon WHERE denygift = 'NO' AND send_gift = 'PEN'";
$sql = mysql_query($query) or die(mysql_error());

while($result = mysql_fetch_assoc($sql))
{
	echo $result['fname'] . " " . $result['lname'] . " - ";
	echo $result['address1']; 
	?> <BR>x<BR> <?
}

 

but fname and lname are not pulled... how do i get that.

 

Thanks

~iPixel

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.