SELECT语句无法正常工作

SELECT语句无法正常工作

我正在使用此代码从我创建的表中检索数据。

SELECT id,shirt_name,boys FROM shirts WHERE boys IS NOT NULL

它不只是选择boys列有输入的行,而是选择所有这些行。下面是我创建表的方式
CREATE TABLE shirts (
    id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
    shirt_name VARCHAR(20) NOT NULL,
    men VARCHAR(10) NULL,
    women VARCHAR(10) NULL,
    boys VARCHAR(10) NULL,
    girls VARCHAR(10) NULL,
    babies VARCHAR(10) NULL,
)ENGINE=INNODB;

INSERT INTO shirts(shirt_name,men,women,boys,girls,babies) VALUES
    ('Crewneck Tee','me_crn','wo_crn','bo_crn','gi_crn','ba_crn'),
    ('V-Neck Tee','me_vnc','wo_vnc','','',''),
    ('Scoop Neck Tee','','wo_sco','','',''),
    ('Raglan Tee','me_rag','wo_rag','bo_rag','gi_rag',''),
    ('Ringer Tee','me_rin','wo_rin','bo_rin','gi_rin',''),
    ('Cap Sleeve Tee','','wo_cap','','gi_cap',''),
    ('Tank Top','me_tan','wo_tan','bo_tan','gi_tan',''),
    ('Spaghetti Strap','','wo_spa','','',''),
    ('Hoodie','me_hod','wo_hod','bo_hod','gi_hod','ba_hod');

我做错了什么?

最佳答案

SELECT id,shirt_name,boys FROM shirts WHERE boys != ''

你需要用这些数据

关于php - SELECT语句无法正常工作,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14087198/

10-13 02:01