question

AiresLiu avatar image
AiresLiu asked

How to execute "select bool expression", like select 1>0 in Mysql?

How to execute "select bool expression", like select 1>0 in Mysql?

select 1>0 cause a compile error in SQL server.

select
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Jon Crawford avatar image
Jon Crawford answered

Use a CASE statement

SELECT CASE WHEN 1>0 THEN 'TRUE' ELSE 'FALSE' END;

there's no real Boolean datatype to use, so you'd be using the output as a decision point. Might not save you time versus comparing actual value to expected value within an IF structure to begin with.

You could put this into a function if you wanted to, and use that to evaluate your two values.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.