在 select 后面使用数字是什么意思?
What does it mean using number behind select?
有两个表:
create table author (id int primary key auto_increment, name varchar(255));
insert into author (name) values ('tingwei');
insert into author (name) values ('jiahui');
insert into author (name) values ('naidan');
insert into author (name) values ('weizhi');
insert into author (name) values ('siyao');
create table book (author_id int primary key auto_increment, book varchar(255));
insert into book (book) values ('I love you');
insert into book (book) values ('I hate you');
insert into book (book) values ('I miss you');
但是不知道这个语句后面用数字1是什么意思"select":
select *
from author
where exists (select 1 from book where book.author_id = author.id)
我已经在网上搜索了一些资料,但一无所获。
SELECT 1
就是这样做的:它选择值 1
。当与 WHERE EXISTS
一起使用时,子查询 returns 的数据无关紧要,只要它 returns 任何数据(换句话说:returns 至少一行)。 =13=]
有两个表:
create table author (id int primary key auto_increment, name varchar(255));
insert into author (name) values ('tingwei');
insert into author (name) values ('jiahui');
insert into author (name) values ('naidan');
insert into author (name) values ('weizhi');
insert into author (name) values ('siyao');
create table book (author_id int primary key auto_increment, book varchar(255));
insert into book (book) values ('I love you');
insert into book (book) values ('I hate you');
insert into book (book) values ('I miss you');
但是不知道这个语句后面用数字1是什么意思"select":
select *
from author
where exists (select 1 from book where book.author_id = author.id)
我已经在网上搜索了一些资料,但一无所获。
SELECT 1
就是这样做的:它选择值 1
。当与 WHERE EXISTS
一起使用时,子查询 returns 的数据无关紧要,只要它 returns 任何数据(换句话说:returns 至少一行)。 =13=]