我检查了几乎所有相关主题,但对我不起作用。 我是初学者 我收到“操作数应包含1列”或“您的sql语法有错误,请检查与您的mysql服务器版本相对应的手册,以找到在第1行''附近使用的正确语法” 这是我的查询:
create database makla;
use makla;
create table orders(
order_id int auto_increment primary key,
order_date DATE
);
create table productionitem(
order_id int not null,
item_name varchar (20),
item_description varchar (100),
constraint order_fk foreign key (order_id) references orders (order_id)
);
insert into orders(order_date) values ('2014/11/4');
insert into orders(order_date) values ('2017/9/30');
insert into orders(order_date) values ('2019/4/13');
insert into productionitem(order_id, item_name, item_description)
values (1, 'tv', 'samsung X');
insert into productionitem(order_id, item_name, item_description)
values (1, 'watch', 'swatch X');
insert into productionitem(order_id, item_name, item_description)
values (2, 'pan', 'metal X');
insert into productionitem(order_id, item_name, item_description)
values (3, 'cup', 'world X');
insert into productionitem(order_id, item_name, item_description)
values (3, 'chair', 'plastic X');
select *
from productionitem
where order_id in (select order_id
from orders
where order_date between '2015/11/4' and '2020/11/4')
请帮助
答案 0 :(得分:1)
您可能需要以正确的格式print
yyyy-mm-dd
相同的日期格式将用于insert into orders(order_date) values ('2014-11-04');
insert into orders(order_date) values ('2017-09-30'); -- notice 09 not just 9
insert into orders(order_date) values ('2019-04-13');
查询。