由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 问个sql 题
相关主题
问个sql问题请教个SQL的问题
49本电子书下载请帮忙回答一个SQL问题
Job opportunity求教一个SQL的问题
问个电话面试时间问题SQL find distinct values in large table (转载)
How can I upload e-bookSQL copy a table into a new table and add a new column (转载)
question about travelSQL multiply all values of a column in table (转载)
SQL combine two columns from two different tables no shared columnsSQL add some columns into a table from another table
delete sheets from Excel workbook in C#SQL fast search in a 10 million records table
相关话题的讨论汇总
话题: books话题: delete话题: price话题: book话题: max
进入JobHunting版参与讨论
1 (共1页)
h******3
发帖数: 351
1
可能讨论过:
Table "books" has columns BOOK_ID, BOOK_TITLE, BOOK_AUTHOR, PRICE, PUBLISH_
DATE. Delete most expensive book from books table.
我try 了
delete max(price), author, publish_date,book_id from books;
sub-query
delete * from books where price in (select max(price) from books);
self-join
delete * from books b1, books b2 where b1.price = b2.price and b2.price in
select max(price);
none of them work. Can anybody tell me one executable SQL statement?
Thanks.
g**********1
发帖数: 1113
2
delete from ....
t*****j
发帖数: 1105
3
delete 肯定是 delete一个row,全部的column啦。

【在 h******3 的大作中提到】
: 可能讨论过:
: Table "books" has columns BOOK_ID, BOOK_TITLE, BOOK_AUTHOR, PRICE, PUBLISH_
: DATE. Delete most expensive book from books table.
: 我try 了
: delete max(price), author, publish_date,book_id from books;
: sub-query
: delete * from books where price in (select max(price) from books);
: self-join
: delete * from books b1, books b2 where b1.price = b2.price and b2.price in
: select max(price);

p*****s
发帖数: 4393
4
try to get rid of your * after delete in your second statement

【在 h******3 的大作中提到】
: 可能讨论过:
: Table "books" has columns BOOK_ID, BOOK_TITLE, BOOK_AUTHOR, PRICE, PUBLISH_
: DATE. Delete most expensive book from books table.
: 我try 了
: delete max(price), author, publish_date,book_id from books;
: sub-query
: delete * from books where price in (select max(price) from books);
: self-join
: delete * from books b1, books b2 where b1.price = b2.price and b2.price in
: select max(price);

d**e
发帖数: 6098
5
delete from books
where price = (select max(price) from books);
commit;

【在 h******3 的大作中提到】
: 可能讨论过:
: Table "books" has columns BOOK_ID, BOOK_TITLE, BOOK_AUTHOR, PRICE, PUBLISH_
: DATE. Delete most expensive book from books table.
: 我try 了
: delete max(price), author, publish_date,book_id from books;
: sub-query
: delete * from books where price in (select max(price) from books);
: self-join
: delete * from books b1, books b2 where b1.price = b2.price and b2.price in
: select max(price);

x***y
发帖数: 633
6
In mySQL,
delete from books
order by price desc
limit 1 \g

【在 h******3 的大作中提到】
: 可能讨论过:
: Table "books" has columns BOOK_ID, BOOK_TITLE, BOOK_AUTHOR, PRICE, PUBLISH_
: DATE. Delete most expensive book from books table.
: 我try 了
: delete max(price), author, publish_date,book_id from books;
: sub-query
: delete * from books where price in (select max(price) from books);
: self-join
: delete * from books b1, books b2 where b1.price = b2.price and b2.price in
: select max(price);

h******3
发帖数: 351
7
tried
delete from books where price = (select max(price) from books);
it doesn't work. Error code: 1093, you can't specify target table "books"
for update in from clause.
h******3
发帖数: 351
8
it works. :P.

【在 x***y 的大作中提到】
: In mySQL,
: delete from books
: order by price desc
: limit 1 \g

1 (共1页)
进入JobHunting版参与讨论
相关主题
SQL fast search in a 10 million records tableHow can I upload e-book
Truncation error import csv file to SQL table (转载)question about travel
SQL 面试问题SQL combine two columns from two different tables no shared columns
问下amazon的ad products大组怎么样啊delete sheets from Excel workbook in C#
问个sql问题请教个SQL的问题
49本电子书下载请帮忙回答一个SQL问题
Job opportunity求教一个SQL的问题
问个电话面试时间问题SQL find distinct values in large table (转载)
相关话题的讨论汇总
话题: books话题: delete话题: price话题: book话题: max