1. There are tested items in the project, but there is a package in the test project, which is a small collection of individual items
2. Now the database is designed, but the sql is poor. Ask for help
- item list
CREATE TABLE tx_detection (
id int UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY COMMENT "ID",
is_list tinyint unsigned not null default 0 comment "0 1",
pid enum("a","b","c","d","e") not null comment "ID",
cid varchar(32) not null default "" comment "id",
title CHAR(22) NOT NULL DEFAULT "" COMMENT "",
description CHAR(50) NOT NULL DEFAULT "" COMMENT "",
content VARCHAR(10000) COMMENT "",
status TINYINT(1) NOT NULL DEFAULT "1" COMMENT "1 0 ",
sort int unsigned not null default 0 comment "",
index(pid)--enum
) ENGINE=MyISAM CHARACTER SET utf8;
- sql statement
INSERT INTO `tx_detection`(`id`, `is_list`, `pid`, `cid`, `title`, `description`, `content`, `status`, `sort`) VALUES (1, 0, "b", "", "1", "", "1", 1, 0);
INSERT INTO `tx_detection`(`id`, `is_list`, `pid`, `cid`, `title`, `description`, `content`, `status`, `sort`) VALUES (2, 0, "b", "", "2", "", "2", 1, 0);
INSERT INTO `tx_detection`(`id`, `is_list`, `pid`, `cid`, `title`, `description`, `content`, `status`, `sort`) VALUES (3, 0, "b", "", "1", "", "3", 1, 0);
INSERT INTO `tx_detection`(`id`, `is_list`, `pid`, `cid`, `title`, `description`, `content`, `status`, `sort`) VALUES (4, 0, "d", "", "4", "4", "4", 1, 0);
INSERT INTO `tx_detection`(`id`, `is_list`, `pid`, `cid`, `title`, `description`, `content`, `status`, `sort`) VALUES (5, 0, "a", "", "5", "5", "5", 1, 0);
INSERT INTO `tx_detection`(`id`, `is_list`, `pid`, `cid`, `title`, `description`, `content`, `status`, `sort`) VALUES (6, 0, "a", "", "6", "6", "6", 1, 0);
INSERT INTO `tx_detection`(`id`, `is_list`, `pid`, `cid`, `title`, `description`, `content`, `status`, `sort`) VALUES (7, 1, "b", "1,3", "A", "A", "A", 1, 0);
- self-written statements
SELECT a.* from tx_detection as a,tx_detection as b where a.id in (select cid from tx_detection where tx_detection.id = 7) and a.id = 7; --
SELECT a.* from tx_detection as a,tx_detection as b where a.id in (1,3) and a.id = 7;--vachar
SELECT a.* from tx_detection as a where a.id in (1,3);
SELECT a.* from tx_detection as a where a.id in (select cid from tx_detection where id = 7);1 vacharwhere id = 7
SELECT a.* from tx_detection as a,tx_detection as b where a.id in (select cid from tx_detection where id = 7) and b.id = 7;
vachar in(1,3)aa.id = 7
add 3 because I see other people say that in ("1pm, no. 3") this is OK. I can also look it up myself. I can really query it
.SELECT a.* from tx_detection as a,tx_detection as b where a.id in ("1","3") and b.id = 7;
then the vachar in the data is changed to the form of "1percent and 3percent".
3. cID cid vachar
4.
id=7 1,3