How do I store a boolean value that takes in yes or no without quotes?
For my assignment I need help storing a boolean value that can hold yes or no. The column name is Required and the column attributes I received are Boolean value (1/0 or T/F) , Default value: NULL
I listed the sample data to be used bellow. The yes/no has to be stored without quotes somehow. Thank you
INSERT INTO CIS_Courses
VALUES ("CIS 105", "Computer Applications and Information Technology", null, Yes);
sql database
add a comment |
For my assignment I need help storing a boolean value that can hold yes or no. The column name is Required and the column attributes I received are Boolean value (1/0 or T/F) , Default value: NULL
I listed the sample data to be used bellow. The yes/no has to be stored without quotes somehow. Thank you
INSERT INTO CIS_Courses
VALUES ("CIS 105", "Computer Applications and Information Technology", null, Yes);
sql database
1
Are you using MySQL or SQL Server ? Please dont tag all the RDBMS. I have remove the RDBMS tags. Edit the question to tag with the specific RDBMS you are using.
– Madhur Bhaiya
Nov 15 '18 at 6:06
I'd guess MySQL. (Based on those double quoted string literals...)
– jarlh
Nov 15 '18 at 7:02
I don't understand the question.Yes
is no value. The string'Yes'
would be. But if your DBMS supports boolean columns, you would rather use this and storetrue
orfalse
. E.g.INSERT INTO CIS_Courses (course_number, title, starting_date, confirmed) VALUES ('CIS 105', 'Computer Applications and Information Technology', null, true);
– Thorsten Kettner
Nov 15 '18 at 7:08
On a sidenote: You should not use double quotes for string literals. The delimiter for string literals is the single quote. The double quote, according to the SQL standard, is for names (table names, column names, etc.).
– Thorsten Kettner
Nov 15 '18 at 7:10
add a comment |
For my assignment I need help storing a boolean value that can hold yes or no. The column name is Required and the column attributes I received are Boolean value (1/0 or T/F) , Default value: NULL
I listed the sample data to be used bellow. The yes/no has to be stored without quotes somehow. Thank you
INSERT INTO CIS_Courses
VALUES ("CIS 105", "Computer Applications and Information Technology", null, Yes);
sql database
For my assignment I need help storing a boolean value that can hold yes or no. The column name is Required and the column attributes I received are Boolean value (1/0 or T/F) , Default value: NULL
I listed the sample data to be used bellow. The yes/no has to be stored without quotes somehow. Thank you
INSERT INTO CIS_Courses
VALUES ("CIS 105", "Computer Applications and Information Technology", null, Yes);
sql database
sql database
edited Nov 15 '18 at 7:01
jarlh
29.8k52138
29.8k52138
asked Nov 15 '18 at 5:54
ChrisChris
1
1
1
Are you using MySQL or SQL Server ? Please dont tag all the RDBMS. I have remove the RDBMS tags. Edit the question to tag with the specific RDBMS you are using.
– Madhur Bhaiya
Nov 15 '18 at 6:06
I'd guess MySQL. (Based on those double quoted string literals...)
– jarlh
Nov 15 '18 at 7:02
I don't understand the question.Yes
is no value. The string'Yes'
would be. But if your DBMS supports boolean columns, you would rather use this and storetrue
orfalse
. E.g.INSERT INTO CIS_Courses (course_number, title, starting_date, confirmed) VALUES ('CIS 105', 'Computer Applications and Information Technology', null, true);
– Thorsten Kettner
Nov 15 '18 at 7:08
On a sidenote: You should not use double quotes for string literals. The delimiter for string literals is the single quote. The double quote, according to the SQL standard, is for names (table names, column names, etc.).
– Thorsten Kettner
Nov 15 '18 at 7:10
add a comment |
1
Are you using MySQL or SQL Server ? Please dont tag all the RDBMS. I have remove the RDBMS tags. Edit the question to tag with the specific RDBMS you are using.
– Madhur Bhaiya
Nov 15 '18 at 6:06
I'd guess MySQL. (Based on those double quoted string literals...)
– jarlh
Nov 15 '18 at 7:02
I don't understand the question.Yes
is no value. The string'Yes'
would be. But if your DBMS supports boolean columns, you would rather use this and storetrue
orfalse
. E.g.INSERT INTO CIS_Courses (course_number, title, starting_date, confirmed) VALUES ('CIS 105', 'Computer Applications and Information Technology', null, true);
– Thorsten Kettner
Nov 15 '18 at 7:08
On a sidenote: You should not use double quotes for string literals. The delimiter for string literals is the single quote. The double quote, according to the SQL standard, is for names (table names, column names, etc.).
– Thorsten Kettner
Nov 15 '18 at 7:10
1
1
Are you using MySQL or SQL Server ? Please dont tag all the RDBMS. I have remove the RDBMS tags. Edit the question to tag with the specific RDBMS you are using.
– Madhur Bhaiya
Nov 15 '18 at 6:06
Are you using MySQL or SQL Server ? Please dont tag all the RDBMS. I have remove the RDBMS tags. Edit the question to tag with the specific RDBMS you are using.
– Madhur Bhaiya
Nov 15 '18 at 6:06
I'd guess MySQL. (Based on those double quoted string literals...)
– jarlh
Nov 15 '18 at 7:02
I'd guess MySQL. (Based on those double quoted string literals...)
– jarlh
Nov 15 '18 at 7:02
I don't understand the question.
Yes
is no value. The string 'Yes'
would be. But if your DBMS supports boolean columns, you would rather use this and store true
or false
. E.g. INSERT INTO CIS_Courses (course_number, title, starting_date, confirmed) VALUES ('CIS 105', 'Computer Applications and Information Technology', null, true);
– Thorsten Kettner
Nov 15 '18 at 7:08
I don't understand the question.
Yes
is no value. The string 'Yes'
would be. But if your DBMS supports boolean columns, you would rather use this and store true
or false
. E.g. INSERT INTO CIS_Courses (course_number, title, starting_date, confirmed) VALUES ('CIS 105', 'Computer Applications and Information Technology', null, true);
– Thorsten Kettner
Nov 15 '18 at 7:08
On a sidenote: You should not use double quotes for string literals. The delimiter for string literals is the single quote. The double quote, according to the SQL standard, is for names (table names, column names, etc.).
– Thorsten Kettner
Nov 15 '18 at 7:10
On a sidenote: You should not use double quotes for string literals. The delimiter for string literals is the single quote. The double quote, according to the SQL standard, is for names (table names, column names, etc.).
– Thorsten Kettner
Nov 15 '18 at 7:10
add a comment |
2 Answers
2
active
oldest
votes
boolean data type is not available in sql server
you can use BIT datatype to represent boolean data.
A BIT field's value is either 1,0 or null
It also use the strings 'true' and 'false' in place of 1 or 0, like so-
declare @a bit = 'false'
print @a --output 0
declare @b bit = 'true'
print @b -- output 1
add a comment |
I always use tinyint(1) as boolean type value. Your table column would look like:
ColumnName tinyint(1) not null default 0
So when you don't insert a value, it will automatically be 0, or you can insert a 0 or 1.
I hope that this will help you
Which DBMS are you referring to? Doesn't your DBMS support a boolean datatype or is there anything that speaks against using it?
– Thorsten Kettner
Nov 15 '18 at 7:38
tinyint
is universal, not all SQL servers support boolean.
– Frosted Developer
Nov 16 '18 at 8:08
Well, tinyint is not universal, but yes, many support it and the others support some numeric datatype, too. So your argument is thatWHERE NOT available
or evenHAVING EVERY(available)
would only run in certain DBMS that support a boolean datatype (and such function), whileWHERE available = 0
orHAVING MIN(available) = 1
would work in all? So you are striving to have your database as portable as possible? That's a fair enough reason.
– Thorsten Kettner
Nov 16 '18 at 9:48
I think it will work out for that case, yes. Since it isn't declared which type of database he's using.
– Frosted Developer
Nov 17 '18 at 10:53
add a comment |
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53313248%2fhow-do-i-store-a-boolean-value-that-takes-in-yes-or-no-without-quotes%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
boolean data type is not available in sql server
you can use BIT datatype to represent boolean data.
A BIT field's value is either 1,0 or null
It also use the strings 'true' and 'false' in place of 1 or 0, like so-
declare @a bit = 'false'
print @a --output 0
declare @b bit = 'true'
print @b -- output 1
add a comment |
boolean data type is not available in sql server
you can use BIT datatype to represent boolean data.
A BIT field's value is either 1,0 or null
It also use the strings 'true' and 'false' in place of 1 or 0, like so-
declare @a bit = 'false'
print @a --output 0
declare @b bit = 'true'
print @b -- output 1
add a comment |
boolean data type is not available in sql server
you can use BIT datatype to represent boolean data.
A BIT field's value is either 1,0 or null
It also use the strings 'true' and 'false' in place of 1 or 0, like so-
declare @a bit = 'false'
print @a --output 0
declare @b bit = 'true'
print @b -- output 1
boolean data type is not available in sql server
you can use BIT datatype to represent boolean data.
A BIT field's value is either 1,0 or null
It also use the strings 'true' and 'false' in place of 1 or 0, like so-
declare @a bit = 'false'
print @a --output 0
declare @b bit = 'true'
print @b -- output 1
answered Nov 15 '18 at 6:02
Zaynul Abadin TuhinZaynul Abadin Tuhin
18.6k21134
18.6k21134
add a comment |
add a comment |
I always use tinyint(1) as boolean type value. Your table column would look like:
ColumnName tinyint(1) not null default 0
So when you don't insert a value, it will automatically be 0, or you can insert a 0 or 1.
I hope that this will help you
Which DBMS are you referring to? Doesn't your DBMS support a boolean datatype or is there anything that speaks against using it?
– Thorsten Kettner
Nov 15 '18 at 7:38
tinyint
is universal, not all SQL servers support boolean.
– Frosted Developer
Nov 16 '18 at 8:08
Well, tinyint is not universal, but yes, many support it and the others support some numeric datatype, too. So your argument is thatWHERE NOT available
or evenHAVING EVERY(available)
would only run in certain DBMS that support a boolean datatype (and such function), whileWHERE available = 0
orHAVING MIN(available) = 1
would work in all? So you are striving to have your database as portable as possible? That's a fair enough reason.
– Thorsten Kettner
Nov 16 '18 at 9:48
I think it will work out for that case, yes. Since it isn't declared which type of database he's using.
– Frosted Developer
Nov 17 '18 at 10:53
add a comment |
I always use tinyint(1) as boolean type value. Your table column would look like:
ColumnName tinyint(1) not null default 0
So when you don't insert a value, it will automatically be 0, or you can insert a 0 or 1.
I hope that this will help you
Which DBMS are you referring to? Doesn't your DBMS support a boolean datatype or is there anything that speaks against using it?
– Thorsten Kettner
Nov 15 '18 at 7:38
tinyint
is universal, not all SQL servers support boolean.
– Frosted Developer
Nov 16 '18 at 8:08
Well, tinyint is not universal, but yes, many support it and the others support some numeric datatype, too. So your argument is thatWHERE NOT available
or evenHAVING EVERY(available)
would only run in certain DBMS that support a boolean datatype (and such function), whileWHERE available = 0
orHAVING MIN(available) = 1
would work in all? So you are striving to have your database as portable as possible? That's a fair enough reason.
– Thorsten Kettner
Nov 16 '18 at 9:48
I think it will work out for that case, yes. Since it isn't declared which type of database he's using.
– Frosted Developer
Nov 17 '18 at 10:53
add a comment |
I always use tinyint(1) as boolean type value. Your table column would look like:
ColumnName tinyint(1) not null default 0
So when you don't insert a value, it will automatically be 0, or you can insert a 0 or 1.
I hope that this will help you
I always use tinyint(1) as boolean type value. Your table column would look like:
ColumnName tinyint(1) not null default 0
So when you don't insert a value, it will automatically be 0, or you can insert a 0 or 1.
I hope that this will help you
answered Nov 15 '18 at 7:26
Frosted DeveloperFrosted Developer
9614
9614
Which DBMS are you referring to? Doesn't your DBMS support a boolean datatype or is there anything that speaks against using it?
– Thorsten Kettner
Nov 15 '18 at 7:38
tinyint
is universal, not all SQL servers support boolean.
– Frosted Developer
Nov 16 '18 at 8:08
Well, tinyint is not universal, but yes, many support it and the others support some numeric datatype, too. So your argument is thatWHERE NOT available
or evenHAVING EVERY(available)
would only run in certain DBMS that support a boolean datatype (and such function), whileWHERE available = 0
orHAVING MIN(available) = 1
would work in all? So you are striving to have your database as portable as possible? That's a fair enough reason.
– Thorsten Kettner
Nov 16 '18 at 9:48
I think it will work out for that case, yes. Since it isn't declared which type of database he's using.
– Frosted Developer
Nov 17 '18 at 10:53
add a comment |
Which DBMS are you referring to? Doesn't your DBMS support a boolean datatype or is there anything that speaks against using it?
– Thorsten Kettner
Nov 15 '18 at 7:38
tinyint
is universal, not all SQL servers support boolean.
– Frosted Developer
Nov 16 '18 at 8:08
Well, tinyint is not universal, but yes, many support it and the others support some numeric datatype, too. So your argument is thatWHERE NOT available
or evenHAVING EVERY(available)
would only run in certain DBMS that support a boolean datatype (and such function), whileWHERE available = 0
orHAVING MIN(available) = 1
would work in all? So you are striving to have your database as portable as possible? That's a fair enough reason.
– Thorsten Kettner
Nov 16 '18 at 9:48
I think it will work out for that case, yes. Since it isn't declared which type of database he's using.
– Frosted Developer
Nov 17 '18 at 10:53
Which DBMS are you referring to? Doesn't your DBMS support a boolean datatype or is there anything that speaks against using it?
– Thorsten Kettner
Nov 15 '18 at 7:38
Which DBMS are you referring to? Doesn't your DBMS support a boolean datatype or is there anything that speaks against using it?
– Thorsten Kettner
Nov 15 '18 at 7:38
tinyint
is universal, not all SQL servers support boolean.– Frosted Developer
Nov 16 '18 at 8:08
tinyint
is universal, not all SQL servers support boolean.– Frosted Developer
Nov 16 '18 at 8:08
Well, tinyint is not universal, but yes, many support it and the others support some numeric datatype, too. So your argument is that
WHERE NOT available
or even HAVING EVERY(available)
would only run in certain DBMS that support a boolean datatype (and such function), while WHERE available = 0
or HAVING MIN(available) = 1
would work in all? So you are striving to have your database as portable as possible? That's a fair enough reason.– Thorsten Kettner
Nov 16 '18 at 9:48
Well, tinyint is not universal, but yes, many support it and the others support some numeric datatype, too. So your argument is that
WHERE NOT available
or even HAVING EVERY(available)
would only run in certain DBMS that support a boolean datatype (and such function), while WHERE available = 0
or HAVING MIN(available) = 1
would work in all? So you are striving to have your database as portable as possible? That's a fair enough reason.– Thorsten Kettner
Nov 16 '18 at 9:48
I think it will work out for that case, yes. Since it isn't declared which type of database he's using.
– Frosted Developer
Nov 17 '18 at 10:53
I think it will work out for that case, yes. Since it isn't declared which type of database he's using.
– Frosted Developer
Nov 17 '18 at 10:53
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53313248%2fhow-do-i-store-a-boolean-value-that-takes-in-yes-or-no-without-quotes%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Are you using MySQL or SQL Server ? Please dont tag all the RDBMS. I have remove the RDBMS tags. Edit the question to tag with the specific RDBMS you are using.
– Madhur Bhaiya
Nov 15 '18 at 6:06
I'd guess MySQL. (Based on those double quoted string literals...)
– jarlh
Nov 15 '18 at 7:02
I don't understand the question.
Yes
is no value. The string'Yes'
would be. But if your DBMS supports boolean columns, you would rather use this and storetrue
orfalse
. E.g.INSERT INTO CIS_Courses (course_number, title, starting_date, confirmed) VALUES ('CIS 105', 'Computer Applications and Information Technology', null, true);
– Thorsten Kettner
Nov 15 '18 at 7:08
On a sidenote: You should not use double quotes for string literals. The delimiter for string literals is the single quote. The double quote, according to the SQL standard, is for names (table names, column names, etc.).
– Thorsten Kettner
Nov 15 '18 at 7:10