Welcome Guest, Not a member yet? Register   Sign In
Append variable to column name during select statement
#1

[eluser]mvdg27[/eluser]
Hi guys,

I'm wondering if there is an easier way to achieve a MySQL select statement where a specific variable name is appended to the column names. Right now I add the variable name explicitly to each column, but perhaps this can be done more easy?

Code:
$var = 'my_var';
$this->db->select('id AS id_'.$var.', foo AS foo_'.$var .... etc. ect.);

Also, this would be useful for when I want to do a select all ('*'), statement .. does anyone know of how this is done?

Thanks, in advance!

-Michiel


Messages In This Thread
Append variable to column name during select statement - by El Forum - 04-19-2009, 09:32 AM
Append variable to column name during select statement - by El Forum - 04-19-2009, 09:40 AM
Append variable to column name during select statement - by El Forum - 04-19-2009, 10:32 AM
Append variable to column name during select statement - by El Forum - 04-19-2009, 12:36 PM
Append variable to column name during select statement - by El Forum - 04-19-2009, 01:57 PM
Append variable to column name during select statement - by El Forum - 04-19-2009, 02:06 PM
Append variable to column name during select statement - by El Forum - 04-19-2009, 02:11 PM
Append variable to column name during select statement - by El Forum - 04-20-2009, 09:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB