首页 文章

如何在插入值命令中插入Bool的值?

提问于
浏览
1

性别是一个Bool值,但我不知道如何插入其值下面是我写的

INSERT INTO用户(user_id,user_name,加入,密码,first_name,last_name,date_of_birth,性别)VALUES('150/08','Otollo',NOW(),SHA('WUODBABA'),'Joshua','Abuto ','1998-08-23',

3 回答

  • 0

    使用真假如

    INSERT INTO users 
    (user_id, user_name, joined, password, first_name, last_name, date_of_birth, gender) 
    VALUES 
    ('150/08', 'Otollo', NOW(), SHA('WUODBABA'), 'Joshua', 'Abuto', '1998-08-23',TRUE)
    

    并使用此链接检查所有可能的方式插入bool值

    http://www.postgresql.org/docs/8.1/static/datatype-boolean.html

  • 0

    只需将 TRUEFALSE 如下所示

    INSERT INTO users 
    (user_id, user_name, joined, password, first_name, last_name, date_of_birth, gender) 
    VALUES 
    ('150/08', 'Otollo', NOW(), SHA('WUODBABA'), 'Joshua', 'Abuto', '1998-08-23',TRUE)
    

    Here you can find more information

  • 0

    你可以做到这一点 .

    我不知道您对该性别列的数据类型 .

    I am assuming that your column datatype is bit

    你只需要在数据库中为性别列传递0和1 .

    INSERT INTO users 
        (user_id, user_name, joined, password, first_name, last_name, date_of_birth, gender) 
        VALUES 
        ('150/08', 'Otollo', NOW(), SHA('WUODBABA'), 'Joshua', 'Abuto', '1998-08-23',0 OR 1)
    

相关问题