2023-09-14 mysql-Item_subselect-分析

摘要:

2023-09-14 mysql-Item_subselect-分析

DDL:

表结构和数据:

drop table t_test;

CREATE TABLE t_test(
  id INT NOT NULL AUTO_INCREMENT,
  first_name VARCHAR(10) NOT NULL,
  last_name VARCHAR(10) NOT NULL,
  sex VARCHAR(5) NOT NULL,
  score INT NOT NULL,
  copy_id INT NOT NULL,
  PRIMARY KEY (`id`)
);

insert into t_test values(1,'张','三','男',10,1),(2,'李','四','女',20,2),(3,'王','五','男',30,3);

查询SQL:

select id,
       first_name,
       (select last_name from t_test where id = 2) as last_name
  from t_test;

核心处理:

Item_singlerow_subselect::val_str

调用堆栈:

#0  Item_singlerow_subselect::val_str (this=0x7f36e819dc78, str=0x7f37804f29c0)

你可能感兴趣的:(mysql,mysql,数据库,Item_subselect)