Hello,
First of all, excuse my poor topic title. I simply have no idea how to formulate this question or what to Google after, so don't shoot me if this is something easy answerable.
Assume I have the following tables:
[AUTHORS] id, name
[NEWS] id, item, author_id
If I wanted to display a news item and output the corresponding author (stored in author_id), I'd do the following query:
SELECT * FROM `news` JOIN `authors` ON news.author_id = authors.id
And then outputting it by doing something like this
$Q = "SELECT * FROM news JOIN authors ON news.author_id=news.id";
$query = $this->lite->query($Q) or die($this->lite->error);
$result=null; while($obj = $query->fetch_object()){
$result.= '<li>'.$obj->item. 'by ' . $obj->name . '</li>';
}
Here, $obj->name would contain the name of the author and would successfully output.
So, what happens if the "name" field were called "item" instead? There would obviously be some conflicts. With my previous experience in Propel & symfony, I would do something like this: getAuthorId()->getName() - but for this project I'm required to write SQL from scratch.
Appreciate all answers! Thanks!