0

i am unable to separte the table with the field from the below query. every query becomes table_name.field_name but i want only field_name as i want to output dummy string from the sql but i am unable to achieve this

$select1 = $dbAdapter->select()
     ->from("list",array("list_id","xyz"));

the above query results generates following sql

SELECT `list`.`list_id`, `list`.`xyz` FROM `list`;

but i want my query as

 SELECT `list`.`list_id`, `xyz` FROM `list`;

how can i achieve this result...??

Ankit Sharma
  • 143
  • 1
  • 10

1 Answers1

0

You should use Expression Column for this. For example

$select = $dbAdapter->select()
    ->from(
        "list",
        array(
            "list_id",
            new Zend_Db_Expr("xyz")
        )
    );

Columns in SQL queries are sometimes expressions, not simply column names from a table. Expressions should not have correlation names or quoting applied.

Victor Smirnov
  • 3,450
  • 4
  • 30
  • 49