Welcome Guest, Not a member yet? Register   Sign In
I am getting sql query problem in CI
#1

[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............
#2

[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");
#3

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

Please check it.......
#4

[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
#5

[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




Theme © iAndrew 2016 - Forum software by © MyBB