I had a little problem after upgrading from 4.7 to 5.1. I received a warning about ambiguous query after posting new content or editing an existing content:
user warning: Column 'tid' in field list is ambiguous query: SELECT tid FROM term_data LEFT JOIN term_data catd ON term_data.tid = catd.tid WHERE (term_data.tid IN (2, 0) OR catd.vid NOT IN (2)) ORDER BY tid LIMIT 305, 1 in C:\xampp\htdocs\drupal-5.1\includes\database.mysql.inc on line 172.
Obviously in this case, I don't need left join because the two tables are the same, so I had to add this check manually ($primary_table == 'term_data'):
// hack BEGIN
//$join = "LEFT JOIN {term_data} catd ON $primary_table.tid = catd.tid"; // commented out
if($primary_table == 'term_data')
$join = "";
else $join = "LEFT JOIN {term_data} catd ON $primary_table.tid = catd.tid";
// hack END
// hack BEGIN
//$where = "$primary_table.tid IN (". implode(', ', $tids) .") OR catd.vid NOT IN (". implode(',', $vids) .")"; // commented out
if($primary_table == 'term_data')
$where = "$primary_table.tid IN (". implode(', ', $tids) .") OR $primary_table.vid NOT IN (". implode(',', $vids) .")";
else
$where = "$primary_table.tid IN (". implode(', ', $tids) .") OR catd.vid NOT IN (". implode(',', $vids) .")";
// hack END
comes from: http://drupal.org/node/148316
Comments
Comment #1
Dave Cohen commentedThanks for the report, and the hack idea. I'm not sure whether that's the best solution. Could be, but I'm not sure.
First, let's figure out what module is making this query. I'm guessing gsitemap. Do you have that installed? If not, what contrib and/or custom modules are installed?
Comment #2
erdtek commentedHi, yes I have installed gsitemap.
Comment #3
amedee-1 commentedI had exactly the same error.
I disabled gsitemap, and the error is gone.
I don't absolutely need gsitemap, but it would be a "nice to have".
Comment #4
Dave Cohen commentedSounds like gsitemap is the problem. I'm not using it. Can one of you try to disambiguate the queries in gsitemap? Anywhere gsitemap uses "tid" in a query, replace it with {term_data}.tid. So for instance
Would become
Just looking through gsitemap.module I see several queries that could be ambiguous.
Comment #5
Dave Cohen commentedClosing due to inactivity.
Comment #6
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.