• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Active Query bug?

PHP Code:
Error Number1052

'id' in field list is ambiguous

`id`, `s_cities`.`id` as `source_city_id`, `d_cities`.`id` as `destination_city_id`, `jobs_raw`.* FROM `jobs_rawLEFT JOIN `cities` as `s_citiesON `s_cities`.`realName`=`jobs_raw`.`source_cityLEFT JOIN `cities` as `d_citiesON `d_cities`.`realName`=`jobs_raw`.`destination_cityWHERE `jobs_raw`.`id` = '38567' 

PHP Code:
$this->db->select('s_cities.id as source_city_id, d_cities.id as destination_city_id, jobs_raw.*');
$this->db->join('cities as s_cities''s_cities.realName=jobs_raw.source_city''left');
$this->db->join('cities as d_cities''d_cities.realName=jobs_raw.destination_city''left');

Notice the Select `id`in the first code block. Its an error that should not happen since that selection is not made in the code. Yet this error shows up. But the funny thing is here that doing this on a different codeigniter install of mine makes it work flawless. Same database, same versions. Latest 3.X

Check rest of your queries - this very well may be when you have done $this->db->select('id') somewhere else, but not executed query with $this->db->get(...);

You could try adding $this->db->reset_query() right before your $this->db->select('s_cities.id as source_city_id, d_cities.id as destination_city_id, jobs_raw.*') to make sure.


I agree with Pertti. If you are still getting the error after that then you can also take your generated sql and try to run it directly in MySQL. If you get the same error then there may be something wrong with the way you constructed your query.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.