Author Topic: exclude keyword in search  (Read 3207 times)

0 Members and 1 Guest are viewing this topic.

Gary Richardson

  • Member
  • **
  • Posts: 2
    • View Profile
exclude keyword in search
« on: 2016-12-02 15:41:04 »
Hi all,

When I come across a photo of my wife, I add the keyword "Anna". When I come across a photo of myself, I add the keyword "Gary". If we're both in the photo, I add two keywords - "Gary" and "Anna".

When I do a search for "Anna", it gives me photos of her and photos of two of us. I want to be able to do a keyword search for photos with "Anna" and NOT "Gary" (i.e. just photos of her alone, not with the two of us). .

The search window doesn't seem to have a != (not equal) option so I guess it's going to have to be some combination of keyword search and and some advanced sql query. I'm ok with basic MySQL queries but this one seems more complex than I can accomplish.

Anyone have an idea how I can come up with a search that'll do what I want?

BTW, I run the TP client on Win7 x64 and the database on a Linux server running MySQL 5.7 (if it even matters).

Thanks for any help!

-Gary

Daan van Rooijen

  • Administrator
  • Sr. Member
  • *****
  • Posts: 938
    • View Profile
exclude keyword in search
« Reply #1 on: 2016-12-02 17:05:59 »
I'm not fluent in SQL either, but if I understand correctly, the sample below will find images with the keyword Mom and NOT keyword Dad:


tn.idthumb in (select distinct idthumb from thumbnailkeyword tk where
tk.idkeyword = (select idkeyword from keyword where keyword = 'Mom')) and
tn.idthumb not in (select distinct idthumb from thumbnailkeyword tk where
tk.idkeyword = (select idkeyword from keyword where keyword = 'Dad'))

Source: [link=http://www.cerious.com/faq_sql.shtml]Cerious' Advanced SQL Search Syntax FAQ[/link]
I'm volunteering as a moderator - I do not work for Cerious Software, Inc.