Repeated paragraph

This section is a repeat of the explanation of the previous query example. It therefore leaves this query example "SELECT `joketext` FROM `joke` WHERE `joketext` LIKE "%programmer%" without an explanation.


Link to content: PHP & MySQL: Novice to Ninja, 7th Edition - Section 3

1 Like

To use the book’s style of notes, the query explanation would be something akin to:

This query will return any joketexts that contain the word programmer anywhere in it. You can combine these search clauses by use of the keywords “AND” or “OR”. See this example:

(I’m unsure from the quoted section whether the book has already explained the meaning of the % wildcard symbol; if not, it would be described here also, I assume.)

1 Like

@m_hutley is essentially correct, though I’d personally word it something like this to encompass both the query above it and the one below it. (disclaimer: I am NOT the author. Just my opinion)

This query will count the number of jokes that have the work programmer in the text. Using the keyword AND would let you set multiple restrictions. For example, in the query below, the query will only return jokes with the word knock in it AND having a date in April 2021

It’s definitely duplicated text, though. I’ll make sure someone sees this…

1 Like

It’s marked for fixing in the next errata phase. Thanks for bringing it to our/their attention.

4 Likes

Weird. The proofed version of the book had this in place of the repeated paragraph:

This query displays the full text of all jokes containing the text “programmer” in their joketext column. The LIKE keyword tells MySQL that the named column must match the given pattern. In this case, the pattern we’ve used is "%programer%". The % signs (called wildcards) indicate that the text “programmer” may be preceded and/or followed by any string of text. (Interestingly, LIKE is case-insensitive, so this pattern will also match a joke that contains “Programmer”, or even “FuNkYProGRammeR”.)

Conditions may also be combined in the WHERE clause to further restrict results. For example, to display knock-knock jokes from April 2021 only, you could use the following query:

7 Likes

Yes, that is weird, you’re correct @ralphm – the issue only appears in the online version of the book in Premium (not any of the ebook versions of the printed version). I’ll ask the dev team to look at what happened and get it fixed.

4 Likes

This is now fixed, thanks for your help everyone!

3 Likes