Robert Holland

May 082014
 

Enum is a good choice for boolean type of fields except that it is treated as a string and not an integer. In this case I just want to set a column in the table to indicate whether the row is active (1) or not (0). I do not want someone to accidentally enter a 2, 3, etc. in the field.

alter table healthtemperature1 add column active_ind enum('0','1') not null;

Article on Enum
May 072014
 
/*
drop database lastinsert_id;
create database lastinsert_id;
use lastinsert_id;
create table foo (id int(11) auto_increment primary key
, text varchar(50) not null)engine=myisam;

create table foo2 (id int(11) auto_increment primary key
, foo_id int(11) not null, text varchar(50) not null)engine=myisam;
*/

INSERT INTO foo (id,text)
    VALUES(NULL,'filename');         # generate ID by inserting NULL
INSERT INTO foo2 (id,foo_id,text)
    VALUES(NULL,LAST_INSERT_ID(),'last_insert_id.sql');  # use ID in second table

Source