- Cari disini...
- Courses
Kategori
Web Development
Mobile Development
Studi Kasus
Fundamental
Pemula
Teknologi Populer
Laravel
PHP
Kotlin
Android
Javascript
Wordpress
Database
Semua Kelas
Flashsale
Popular
Mentor
Roadmap
- Explore
Karir
Temukan Karirmu
Tutorial & Artikel
Temukan Artikel menarik
Podcast
Podcast seputar pemrograman
Webinar
Ikuti Berbagai Webinar
Event
Temukan Event menarik
Beasiswa
Program Beasiswa
Discord
Komunitas Discord
Forum
Diskusi antar Programmer
Leaderboard
Ranking siswa Codepolitan
- Partnership
For Company
Solusi tepat untuk perusahaan
For School
Kerjasama untuk sekolah
For Campus
Kerjasama untuk kampus
For Mentor
Peluang penghasilan untuk mentor
LoginRegister
NOT LIKE operator
MySQL NOT LIKE is used to exclude those rows which are matching the criterion followed by LIKE operator.
Syntax:
expr NOT LIKE pat [ESCAPE 'escape_char']
- Pattern matching using SQL simple regular expression comparison. Returns 1 [TRUE] or 0 [FALSE]. If either expr or pat is NULL, the result is NULL.
- The pattern need not be a literal string. For example, it can be specified as a string expression or table column.
- Per the SQL standard, LIKE performs matching on a per-character basis, thus it can produce results different from the = comparison operator.
- LIKE operator uses WILDCARDS [i.e. %, _] to match the pattern. This is very useful to check whether a particular character or string is present in the records.
% is used to match
any number of characters, even zero characters.
_ is used to match exactly one character.
To test for literal instances of a wildcard character, precede it by the escape character. If you do not specify the ESCAPE character, “\” is assumed.
\% is used to match one "%" character.
\_ Matches one "_" character
MySQL Version: 5.6
Example: MySQL NOT LIKE operator with [%] percent
The following MySQL statement excludes those rows from the table author, having the 1st character of aut_name ‘W’.
Code:
SELECT aut_name, country
FROM author
WHERE aut_name NOT LIKE 'W%';
Relational Algebra Expression:
Relational Algebra Tree:
Sample table: author
Sample Output:
mysql> SELECT aut_name, country -> FROM author -> WHERE aut_name NOT LIKE 'W%'; +----------------------+-----------+ | aut_name | country | +----------------------+-----------+ | S.B.Swaminathan | India | | Thomas Morgan | Germany | | Thomas Merton | USA | | Piers Gibson | UK | | Nikolai Dewey | USA | | Marquis de Ellis | Brazil | | Joseph Milton | USA | | John Betjeman Hunter | Australia | | Evan Hayek | Canada | | E. Howard | Australia | | C. J. Wilde | UK | | Butler Andre | USA | +----------------------+-----------+ 12 rows in set [0.00 sec]
PHP script:
example-not-like - php mysql examples | w3resource
List of authors whose names are not started with 'W', along with their country:
AuthorsCountry
Chủ Đề