Jump to content

Recommended Posts

I have defined a field in my database table which has only two values -Yes or No, since the entries with Yes are few in number in the table I had entered only those and the rest I wanted that the table shoud take as 'No' by default.

 

So I have tried the following options for it for datatype ut in none of the cases the default value shows up.

 

alter table cryptovir change vacinfo vacinfo enum('No','Yes') NOT NULL;

 

alter table cryptovir change vacinfo vacinfo varchar(3) default 'No' NOT NULL;

 

Then I do select * from cryptovir where vacinfo='No';

But it says empty set

Link to comment
https://forums.phpfreaks.com/topic/132523-default-value-not-showing-up/
Share on other sites

As far as I know tinyint data type is to store small numbers.

 

To use 0 and 1 I have to substitute 1 in place of 'Yes'.

 

tinyint is also comonly used to store boolean values, and a yes/no column is exactly that. Of course you can also use ENUM as in one of your examples. Just don't use varchar.

 

As for why UPDATE query affected 0 rows... I have no clue now... Could you paste a row from your table, where you would like to set 'vacinfo' to 'No' ? Doesn't have to be whole row.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.