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
https://forums.phpfreaks.com/topic/75200-selecting-distinct-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.