#1052 - Column 'id' in field list is ambiguous

#1052 - Column 'id' in field list is ambiguous

pakypaky Posts: 106Questions: 0Answers: 0
edited April 2012 in General
Hi all, I've a problem with field name :(

here the error
[code]
CDbException
CDbCommand ha riportato un errore nell'esecuzione della query SQL: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in field list is ambiguous. The SQL statement executed was:
SELECT SQL_CALC_FOUND_ROWS id, cognome, nome, sesso, nascita_data, nascita_luogo, cf
,comuni.id, comuni.nome
FROM tbl_paziente
LEFT JOIN comuni ON comuni.id = tbl_paziente.nascita_luogo
[/code]

here my code:
[code]

/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "id";
/* DB table to use */
$sTable = "tbl_paziente";
$aColumns = array("id", "cognome", "nome", "sesso", "nascita_data","nascita_luogo","cf");

//. order
//. limit
//. etc.....

$sQuery = "
SELECT SQL_CALC_FOUND_ROWS ".str_replace(" , ", " ", implode(", ", $aColumns))."
,comuni.id, comuni.nome
FROM $sTable
LEFT JOIN comuni ON comuni.id = $sTable.nascita_luogo
$sWhere
$sOrder
$sLimit
";
[/code]

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    You'd probably be better asking on an SQL forum as this is more of an SQL problem. However, the problem is likely the $sIndexColumn = "id" variable - you probably need to add a table name in front of it.

    Allan
  • pakypaky Posts: 106Questions: 0Answers: 0
    Try now and tell you ;) tnx
  • pakypaky Posts: 106Questions: 0Answers: 0
    Not :( I renamed fields .... in phpmyadmin !!!
This discussion has been closed.