gpt4 book ai didi

sql - Postgres Like 语句无法正确阅读

转载 作者:行者123 更新时间:2023-11-29 14:32:19 26 4
gpt4 key购买 nike

我一直在努力弄清楚为什么这个 LIKE 语句不能正确阅读。

CREATE VIEW sole_python_author(author_first_name, author_last_name,book_title)
AS SELECT
authors.first_name,authors.last_name, books.title
FROM authors, books
WHERE books.author_id = authors.author_id AND books.title LIKE '%python%';

如果我删除“python”,示例输出是这样的:

author_first_name | author_last_name |         book_title          
-------------------+------------------+-----------------------------
Stephen | King | The Shining
Frank | Herbert | Dune
Arthur C. | Clarke | 2001: A Space Odyssey
Seuss | Theodor | The Cat in the Hat
Seuss | Theodor | Bartholomew and the Oobleck
Paulette | Bourgeois | Franklin in the Dark
Margaret Wise | Brown | Goodnight Moon
Louisa May | Alcott | Little Women
Margery Williams | Bianco | The Velveteen Rabbit
Burne | Hogarth | Dynamic Anatomy
Edgar Allen | Poe | The Tell-Tale Heart
Mark | Lutz | Programming Python
Mark | Lutz | Learning Python
Tom | Christiansen | Perl Cookbook
John | Worsley | Practical PostgreSQL

但是,当我将“python”添加到代码时,它返回 0 行。我相信问题在于 like 声明,但我不确定。我正在尝试获取如下输出:

 Mark              | Lutz             | Programming Python
Mark | Lutz | Learning Python

或者我的语句是否正确执行并且输出应该是 0 行?

最佳答案

LIKE 关键字以区分大小写的方式匹配字符串。我认为您想使用类似于 LIKE 但不区分大小写的 ILIKE

关于sql - Postgres Like 语句无法正确阅读,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49841327/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com