Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you return a constant from an sql statement?

Tags:

How do I return a constant from an sql statement?

For example how would I change the code below so "my message" would return if my (boolean expression) was true

if (my boolean expression)  "my message" else  select top 1 name from people; 

I am using ms sql 2000

like image 570
wusher Avatar asked Nov 20 '08 02:11

wusher


People also ask

How do you do a constant in SQL?

A constant, also known as a literal or a scalar value, is a symbol that represents a specific data value. The format of a constant depends on the data type of the value it represents.

Can a SQL query return a value?

The RETURN statement is used to unconditionally and immediately end an SQL procedure by returning the flow of control to the caller of the stored procedure. When the RETURN statement runs, it must return an integer value.

What is constant query?

The Constant query expression (cq) is a part of the combined query expression (the cq value) similar to the advanced query expression ( aq ), but that must hold expressions such as a search scope that are constant for all users of a specific search interface or search tab.

What does in operator return in SQL?

The IN operator checks a value within a set of values separated by commas and retrieve the rows from the table which are matching. The IN returns 1 when the search value present within the range otherwise returns 0.


Video Answer


1 Answers

Did you try:

select 'my message'; 
like image 58
Ned Batchelder Avatar answered Sep 30 '22 02:09

Ned Batchelder