The syntax for the alias is correct. Its how your using the whole query mechanism. Typically you'll query two or more tables in order to return records with relative data from each table. Hence the concept of a relational database.
Two tables:
tbl1.user_id, tbl1.user_name
tbl2.login_user, tbl2.login_date
Table 1 contains user data while Table 2 contains log in dates for each user (by inserting the user_id).
Code: Select all
SELECT a.*, b.* FROM tbl1 AS a JOIN tbl2 AS b ON a.user_id=b.login_user LIMIT 1;
This would return the first row where there was a match.
In Controller:
| user_id | user_name | login_user | login_date |
| 21 | Joe Doe | 21 | 2013-01-31 14:20:30 |
You would see this result inside PHP with
Code: Select all
while ($row=mysql_fetch_assoc($rs)){
print_r($row);
}
Array (
[user_id]=>21,
[user_name]=>Joe Doe,
[login_user] => 21
[login_date] => 2013-01-31 14:20:30
)
In the above fictional tables, user_id and login_user are the same, so MySQL returns a result that can be output or assigned. But the key was JOIN and common data that would put the two tables together in to one row.