Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
|
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 22nd, 2006, 02:44 PM
Authorized User
 
Join Date: Jan 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Convert from bool

I am using a datagrid and one column is a boolian value. My SQL statement works fine, but I want to display 'TRUE' or 'FALSE' in the column instead of '0' or '1'. I think that I need the CONVERT() function, but I don't know the syntax to use. Does anybody know how to do this?

 
Old May 22nd, 2006, 11:55 PM
Authorized User
 
Join Date: Mar 2006
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello,
You can do it by many ways...
One of them is---->

mysql> select if(1,'true','false');
+----------------------+
| if(1,'true','false') |
+----------------------+
| true |
+----------------------+
1 row in set (0.03 sec)

mysql> select if(0,'true','false');
+----------------------+
| if(0,'true','false') |
+----------------------+
| false |
+----------------------+
1 row in set (0.00 sec)

Regards
Milind







Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot implecitly convert type bool to string vaidyapragati General .NET 1 May 4th, 2007 09:10 PM
cant implicitly convert type int to bool muskaanbajaj BOOK: ASP.NET Website Programming Problem-Design-Solution 3 November 19th, 2005 04:57 PM
Cannot implicitly convert type int to bool muskaanbajaj General .NET 12 May 5th, 2005 03:57 AM
How to Convert a int in a bool with FormatStrings ShadowMoon Classic ASP Basics 2 October 26th, 2004 05:53 AM
Can't convert type 'bool' to 'int' Gjerstad BOOK: ASP.NET Website Programming Problem-Design-Solution 2 July 9th, 2003 10:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.