I have two tables that are joined. Both have an id column.
$query
->select($db->quoteName(array(
'a.id',
'a.address_one',
'a.address_three',
'a.address_two',
'b.id AS myStuff',
'b.person_id'
'b.packages_id',
'b.payment_date',
)))
->from($db->quoteName('#__person','a'))
->join('INNER', $db->quoteName('#__licence', 'b') . ' ON (' . $db->quoteName('a.id') . ' = ' . $db->quoteName('b.person_id') . ')')
->where($db->quoteName('a.published') . ' = '. $db->quote('1'))
->where($db->quoteName('b.published') . ' = '. $db->quote('1'));
However the AS clause doesn't work and throws an error.
the returned query has b
.id AS myStuff
,
rather than
b
.id
AS myStuff,
I've tried all the combinations I can think of for the clause but no matter what I use I get an error.
Can someone tell me that correct format for using an AS clause in the query?
Update
So I've found that if I remove the b.id AS line and then add a separate
$query->select('b.id AS myStuff');
the query works although the ` marks are missing. Not sure if I'm missing some other way of tackling it all within the original query.