1

I have following query:

$query = $this->db->query("SELECT u.query, u.keyword, 
                                  u.language_id as lid, l.code, l.directory 
                           FROM " . DB_PREFIX . "url_alias u 
                           left join " . DB_PREFIX . "language l 
                                  on u.language_id = l.language_id 
                            WHERE u.keyword = '" . $this->db-    >escape($part) . "'");

now I want to exclude some keywords from the query like "blog".

is this possible and how?

3
  • u.keyword <> 'blog'? Commented Dec 20, 2015 at 17:40
  • Or u.keyword NOT IN ('blog', 'blogs', ...) Commented Dec 20, 2015 at 17:42
  • or u.keyword not like 'blog%'. Commented Dec 20, 2015 at 17:45

2 Answers 2

1

I suspect that you have multiple keywords assigned to a "query", and you want "query"s that satisfy the conditions. If this is correct, then you want something like this:

SELECT u.query, GROUP_CONCAT(u.keyword) as keywords,
       u.language_id as lid, l.code, l.directory 
FROM url_alias u left join
     language l 
     on u.language_id = l.language_id 
WHERE u.keyword in
GROUP BY u.query, l.language_id
HAVING SUM(u.keyword = $part) > 0 AND
       SUM(u.keyword IN (<exclude words list>)) = 0;

This returns the queries that have a particular keyword but not others.

Sign up to request clarification or add additional context in comments.

2 Comments

Probably i should give some more info. It's an opencart website running journal theme. This theme adjust the seo module form opencart. Now i also run a seo module besides that. All goes well except for the "blog module". This apends first from the theme itself (like: website/blog-nl or website/blog-de. Now the other seo module appends further (for multilanguage) like: website/blog-nl/nl or website/blog-de/de These urls cannot be found. as far as my knowledge goes, the selection on where to append these /nl or /en is done in query i wrote (including more code).
the website is test.bestgrowproducts.com. all url;s go ok but when you click on the blog (top-right) it cannot find the page (in none of the languages) If you delete the /de or /en it can. Normal mod rewrite doent work because of the mods within opencart.
0

As the comments suggest, just as you use where u.keyword = etc, instead use where u.keyword <> (<> means DOES NOT EQUAL) or you could also use pattern matching where u.keyword NOT LIKE '%string%'

Hope this helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.