CodeIgniter Forums
I am getting sql query problem in CI - 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: I am getting sql query problem in CI (/showthread.php?tid=4418)



I am getting sql query problem in CI - El Forum - 11-23-2007

[eluser]MASS MASS[/eluser]
I Have two tables table_one and table_two

table_one have 3 fields
1) id
2) name
3) date

table_two have 2 fields
1) id
2) table_one_id

I am using join operation...........as shown below

code
-------

$query = $this->db->query("select * from table_one T join table_two W on T.id = W.table_one_id");


from above i am getting only table_two id(field)......i am not getting table_one id(field)
because of ....both tables contain id field same.....

what is the solution for this............


I am getting sql query problem in CI - El Forum - 11-23-2007

[eluser]xwero[/eluser]
Code:
$query = $this->db->query("select T.id as idone, W.id as idtwo from table_one T join table_two W on T.id = W.table_one_id");



I am getting sql query problem in CI - El Forum - 11-23-2007

[eluser]MASS MASS[/eluser]
Your query will also get only one id..........

Please check it.......


I am getting sql query problem in CI - El Forum - 11-23-2007

[eluser]xwero[/eluser]
this works
Code:
select T.id as idone, W.id as idtwo from table_one T, table_two W where T.id = W.table_one_id
If i use your syntax i get an error in phpmyadmin


I am getting sql query problem in CI - El Forum - 11-23-2007

[eluser]MASS MASS[/eluser]
This is perfectly Working.........

You are Great.......

Thank you

I think you have lot of experience with CI and PHP....


Once again....Thank you soooooooooo much.......XWERO