loading..
Русский    English
11:17

Renaming the columns and calculations in the result set page 3

MySQL

The query

  1. SELECT 'SELECT' "SELECT"
will give us upon execution

SELECTSELECT

I can explain this behaviour by default settings which adopt usage of double quote symbol (") in the same manner as single quote (') - for delimiting the character constant. So two string unites into one string. However if you type the query as

  1. SELECT 'SELECT' AS "SELECT";
or as

  1. SELECT 'SELECT' `SELECT`;
you'll obtain desired result.

To forbid usage of double quote as single quote, you can replace settings by standard ones. The following statement changes the setting mentioned above:

  1. SET GLOBAL sql_mode='ANSI_QUOTES';
but this one makes all the settings as standard ones:

  1. SET GLOBAL sql_mode='ANSI';

After that the query

  1. SELECT 'SELECT' "SELECT";
will give us

SELECT
SELECT

Oracle & PostgreSQL

These DBMS behave in standard manner. Note only that Oracle (in view of FROM clause is mandatory)  demands to rewrite our query as

  1. SELECT 'SELECT' "SELECT" FROM dual;


Pages 1 2 3
Tags
aggregate functions Airport ALL AND AS keyword ASCII AVG Battles Bezhaev Bismarck C.J.Date calculated columns Cartesian product CASE cast CHAR CHARINDEX Chebykin check constraint classes COALESCE common table expressions comparison predicates Computer firm CONSTRAINT CONVERT correlated subqueries COUNT CROSS APPLY CTE data type conversion data types database schema DATEADD DATEDIFF DATENAME DATEPART DATETIME date_time functions DDL DEFAULT DEFAULT VALUES DELETE DISTINCT DML duplicates edge equi-join EXCEPT exercise (-2) More tags
The book was updated
several days ago
©SQL-EX,2008 [Evolution] [Feedback] [About] [Links] [Team]
All right reserved.