iPixel Posted October 29, 2007 Share Posted October 29, 2007 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 More sharing options...
Barand Posted October 29, 2007 Share Posted October 29, 2007 To pull them you have to select them try SELECT fname, lname, address1 FROM imgcon WHERE denygift = 'NO' AND send_gift = 'PEN' GROUP BY address1 Link to comment https://forums.phpfreaks.com/topic/75200-selecting-distinct-question/#findComment-380390 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.