w3resource

SQL Exercises: Display a given string

SQL Basic Select Statement: Exercise-2 with Solution

Write a query to display a string "This is SQL Exercise, Practice and Solution".

Sample Solution:

SELECT "This is SQL Exercise, Practice and Solution";

Output of the Query:

?column?
This is SQL Exercise, Practice and Solution

Code Explanation:

The query in SQL that selects a string or a text "This is SQL Exercise, Practice and Solution" as a single column and single row.

Practice Online


Note: You can use literal string (enclosed in single or double quotation mark) just like we use a column name in the SELECT statement. If you use the literal string with a column then it will be displayed in every row of the query results.

Syntax of display a given string

Visual presentation:

Result of display a given string

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous SQL Exercise: Display all information about all salespeople.
Next SQL Exercise: Display the numbers in columns.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.

SQL: Tips of the Day

Is SQL syntax case sensitive?

The SQL Keywords are case-insensitive (SELECT, FROM, WHERE, etc), but are often written in all caps. However in some setups table and column names are case-sensitive. MySQL has a configuration option to enable/disable it. Usually case-sensitive table and column names are the default on Linux MySQL and case-insensitive used to be the default on Windows, but now the installer asked about this during setup. For MSSQL it is a function of the database's collation setting.

Ref: https://bit.ly/3R2iyNZ

 





We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook