就像Command不能使用Oracle SQL一样

时间:2015-10-03 02:36:06

标签: sql database oracle sql-like

我是数据库和PHP的新手。在我的代码中,我试图从PHP脚本中创建一个表,这就是我所拥有的。

create table booktable(BookID INT PRIMARY KEY,
                   BookName VARCHAR(100),
                   Published DATE,
                   Price NUMBER(18,2),
                   Author1 VARCHAR2(30),
                   Author2 VARCHAR2(30));

INSERT INTO booktable (BookID, BookName, Published, Price, Author1, Author2)
VALUES (1, 'Fundamentals of Digital Logic with VHDL Design','14-APR-08', 190.25,'Stephen Brown','Zvon Ko G.Vranesic');
INSERT INTO booktable (BookID, BookName, Published, Price, Author1, Author2)
VALUES (2, 'Distributed Systems Principles and Paradigm','26-JUL-13', 197.80,'Andrew S. Tanenbaum','Maarten Van Steen');
INSERT INTO booktable (BookID, BookName, Published, Price, Author1, Author2)
VALUES (3, 'Eat Real Food The Only Solution to Permanent weight Loss and Disease Prevention','1-APR-15', 29.99,'David Gillespie','');
INSERT INTO booktable (BookID, BookName, Published, Price, Author1, Author2)
VALUES (4, 'Introduction to Computational Science Modeling and Simulation for the sciences','2-MAY-06', 132.75,'Angela B.Shiflet','George W. Shiflet');
INSERT INTO booktable (BookID, BookName, Published, Price, Author1, Author2)
VALUES (5, 'Live Well on Less A Practical Guide to Running a Lean Household','27-MAY-15', 19.00,'Jody Allen','');
INSERT INTO booktable (BookID, BookName, Published, Price, Author1, Author2)
VALUES (6, 'Middle School: Just My Rotten Luck','1-JUL-15', 15.99,'James Patterson','');
INSERT INTO booktable (BookID, BookName, Published, Price, Author1, Author2)
VALUES (7, 'Clementine Rose and the Birthday Emergency','1-JUL-15', 12.99,'Jacqueline Harvey','');
INSERT INTO booktable (BookID, BookName, Published, Price, Author1, Author2)
VALUES (8, 'My Life It''s a long story','26-MAY-15', 32.99,'Willie Nelson','');
INSERT INTO booktable (BookID, BookName, Published, Price, Author1, Author2)
VALUES (9, 'Sword of Summer Magnus Chase','7-OCT-15', 15.99,'Rick Riordan','');

表已成功创建,但是当我尝试运行查询时

`SQL> select * 
      from booktable
      where bookname like '%my%';`

它表示没有选择任何行。我无法弄清楚我做错了什么。感谢。

2 个答案:

答案 0 :(得分:2)

@alfasin是对的。你也可以降低你想要做的事情

select * from booktable where lower(bookname) like '%my%';

答案 1 :(得分:1)

那是因为它区分大小写并且您在某些字段中包含My - 而不是my

尝试改为:

select * 
from booktable
where bookname like '%My%';