I have MySQL database and i want to select distinct City and StateInitials + Zipcode of the selected City & State
I do not want to distinct all fields because then i will get 10+ for all major citys
here is what i have for Distinct City, StateInitials
$rs = mysql_query('select Distinct StateInitials, City from locations where City like "'. mysql_real_escape_string($_REQUEST['term']) .'%" limit 0,15', $dblink);
I want something like => Springfield, Mo, 65801
but dont want it to list => Springfield, Mo, 65802 Springfield, Mo, 65803
try use GROUP BY instead
$term =mysql_real_escape_string($_REQUEST['term']);
$rs = mysql_query("
select StateInitials, City
from locations
where City like '$term%'
GROUP BY StateInitials, City
limit 0,15", $dblink);
Idont know why you say the third , while your query is only 2 columns :).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.