First of all, I might be being blind so apologies in advance.
I have the query
$result2 = mysql_query("SELECT boroughs.borough,partial_postcodes.postcode FROM boroughs JOIN full_postcodes ON boroughs.id = partial_postcodes.borough_id WHERE postcode = '".$parts[0]."'") or die(mysql_error());
I get the error message
Unknown column 'partial_postcodes.postcode' in 'field list'
However when I run a query on the table
$table_query = mysql_query("SHOW COLUMNS FROM partial_postcodes") or die(mysql_error());
while ($columns = mysql_fetch_assoc($table_query))
dump($columns);
I get
array(6) {
["Field"]=>
string(2) "id"
["Type"]=>
string(7) "int(11)"
["Null"]=>
string(2) "NO"
["Key"]=>
string(3) "PRI"
["Default"]=>
NULL
["Extra"]=>
string(14) "auto_increment"
}
array(6) {
["Field"]=>
string(8) "postcode"
["Type"]=>
string(11) "varchar(15)"
["Null"]=>
string(2) "NO"
["Key"]=>
string(0) ""
["Default"]=>
NULL
["Extra"]=>
string(0) ""
}
array(6) {
["Field"]=>
string(10) "borough_id"
["Type"]=>
string(7) "int(11)"
["Null"]=>
string(2) "NO"
["Key"]=>
string(0) ""
["Default"]=>
NULL
["Extra"]=>
string(0) ""
}
which shows that there is a field called postcode in the partial_postcodes table 😕
What's bizarre is that is a couple of a query run on a different table with exactly the same fields but with the table name changed and that query works.