|
Posted by bender on 12/03/07 23:06
J.O. Aho wrote:
Thanks for an answare, but...
>
> SELECT * FROM teble1, table2 WHERE table1.id = table2.id;
>
> If you want only a limited number of columns
>
> SELECT table1.col1,table1.col2,table2.col2, table2.col5 FROM teble1, table2
> WHERE table1.id = table2.id;
>
>
I want to select all columns from two tables (or three or more if
necessary) without alias for each column
>> $rs = $this->dbc->query($sql->createSelect());
>> while($row=$rs->fetch_array()){
>> $retVal[]=$row[table.fieldName] // doesnt work, $row[fieldName]
>> //does work
>> }
>
> In PHP you will only get the column name as the array cell key name when you
> use fetch_array, so $row['fieldName'] will work, you can get trouble if you
> have columns with the same name, I suggest you in those cases use AS in your
> query to rename those
>
> SELECT table1.col1,table1.col2 AS col2-1,table2.col2 AS col2-2, table2.col5
> FROM teble1, table2 WHERE table1.id = table2.id;
>
> This way you won't have trouble with cell keys having hte same name.
>
>
In PHP4 was mysql_result which produced resultset with
tableName.fieldName (if my memory is good:
$mysql_result($rs,$i,tableName.fieldName)) and I wonder if is possible
to get in PHP5 with mysqli?
Navigation:
[Reply to this message]
|