![]() |
database Error Number: 1052 - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: database Error Number: 1052 (/showthread.php?tid=32545) |
database Error Number: 1052 - El Forum - 07-27-2010 [eluser]Unknown[/eluser] Hello all im trying to execute sql statement that retrieve data from two tables that have same column name which is id to distinguish between the id from t_employees table i added t_employees.id in the where statement but my problem is that it does not appears in the SQL statement,what i write is: $where=array('t_employees.id'=>$id); but i still get the follwing error: A Database Error Occurred Error Number: 1052 Column 'id' in where clause is ambiguous SELECT *, `t_employees`.`id` id FROM (`t_employees`) JOIN `t_descriptions` ON `t_descriptions`.`id` = `t_employees`.`t_descriptions_id` WHERE `id` = '24' ORDER BY `t_employees`.`id` asc i dont know why it appears id=24 although i add t_employees.id in the where statement can any body help me thanks database Error Number: 1052 - El Forum - 07-27-2010 [eluser]mddd[/eluser] Maybe the problem is not the WHERE but the SELECT part. You say: Code: SELECT *, t_employees.id id Change the alias name. Then you can choose: use the WHERE clause with the full name (table.column) or the alias. Both will work. database Error Number: 1052 - El Forum - 07-27-2010 [eluser]Rahul Anand[/eluser] add the table name before the * like t_employees.*, may be that is creating problem. check this and let me know if this help Thanks Rahul Anand [email protected] database Error Number: 1052 - El Forum - 07-27-2010 [eluser]danmontgomery[/eluser] the "Column X in where clause is ambiguous" means you have two or more columns called 'id' in your result set, and need to specify the table (in the where clause, not necessarily in the select). |