有問題的客戶數的計數誰沒有聘請汽車使用NOT IN與查詢計數
create table customer
(customer_id char(4) primary key not null,
customer_sname varchar (30) not null,
customer_fname varchar (30) not null,
customer_title varchar (6) not null,
customer_address1 varchar (35) not null,
customer_address2 varchar (35) null,
customer_postcode varchar (25) null,
customer_phone varchar (30) null,
customer_email varchar (40) null,
customer_di varchar (40) not null)
ENGINE=InnoDB;
create table car_booking
(booking_id INTEGER AUTO_INCREMENT primary key not null,
car_id char (4) not null,
customer_id char (4) not null,
hire_sdate date not null,
hire_edate date not null)
engine=innodb;
這似乎並不工作
SELECT customer_id count(*)
FROM customer
WHERE customer_id not IN
(SELECT booking_id FROM car_booking
幫助我: - (
請格式化。使用編輯框頂部的工具欄。選擇每個代碼塊並用1和0按下圖標。 – 2010-07-04 12:22:13
@sAc感謝一大堆! – 2010-07-04 12:22:56
用於發佈您的表格結構。這使事情變得更容易。如果你還解釋了爲什麼*你認爲你的查詢不起作用以及你得到了什麼錯誤信息,你將得到+2。除了StackOverflow不允許我投票+2。 – 2010-07-04 12:32:23