0

以下是我的表的脚本:

create table PRODUCTS
(ProdID   integer      Not null,
 Descrip  varchar(50)  Not null,
     Price    decimal(4,2),
     Primary key(ProdID));


insert into PRODUCTS values (100860,'ace tennis racket I',65.00);
insert into PRODUCTS values (100861,'ace tennis racket II',58.00);
insert into PRODUCTS values (100870,'ace tennis balls-3 pack',15.80);
insert into PRODUCTS values (100871,'ace tennis balls-6 pack',10.00);
insert into PRODUCTS values (100890,'ace tennis net',74.00);
insert into PRODUCTS values (101860,'sp tennis racket',37.00);
insert into PRODUCTS values (101863,'sp junior racket',25.00);
insert into PRODUCTS values (102130,'rh: "guide to tennis"',8.95);
insert into PRODUCTS values (200376,'sb energy bar-6 pack',7.00);
insert into PRODUCTS values (200380,'sb vita snack-6 pack',8.40);

如何编写描述有“球拍”的选择脚本,而我不必完全输入“ace网球拍I”、“ace网球拍II”或“初级球拍”来获取所有球拍?

4

2 回答 2

5

你只需使用

select * from PRODUCTS where Descrip LIKE '%racket%'

你可以在这里查看 SQL 模式匹配:http: //dev.mysql.com/doc/refman/5.0/en/pattern-matching.html

于 2013-03-27T21:28:44.067 回答
0
    select * from Products where INSTR(Descrip, 'racket') > 0;
于 2013-03-27T21:30:31.273 回答