How to set an alias to a fields on a db_select? Like it said on the title, as we use alias to fields with a static query, i want to do same thing with a dynamic query

example :

with static select : $sql = db_query ("SELECT my_super_long_field as mslf FROM {super_long_table} as slt")

How to perform same with a db_select query please ?

$sql = db_select ('super_long_table','slt')
-&gt;fields('slt',array('mys_super_long_field', 'here i want alias for long fields')


Thank you
Use addField(). Here's an example:

$query = db_select('super_long_table', 'slt');
$query-&gt;addField('slt', 'mys_super_long_field', 'mslf');


Arguments passed to addField() are:


Table alias
Field - your long field name will be here
Alias - your short field alias will be here


Read more about it here.