04-15-2011, 08:46 PM | #1 |
Junior Member
Posts: 2
Karma: 10
Join Date: Apr 2011
Device: Kindle
|
Help with search syntax please.
I need to know how to search for all books that have the same value in the author and title fields. I made a mistake and stripped out some data and need this to recover.
I thought it might be: author:=title: but it doesn't work. I don't seem to be able to compare one field with another in the search. Any advice would be appreciated. Thanks in advance, Rob. |
04-15-2011, 09:27 PM | #2 |
Wizard
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
You can't. At least, not with a search. You can create a composite column that compares the author and title fields and produces 'yes' or 'no' as appropriate with the 'strcmp' function.
|
Advert | |
|
04-16-2011, 12:18 AM | #3 |
Junior Member
Posts: 2
Karma: 10
Join Date: Apr 2011
Device: Kindle
|
Thanks for the reply. I was able to get what I needed thanks to your advice but I used a dirtier method initially.
{author:contains({title}, true, false)} With some perseverence I got to what you intended (I think): {:'strcmp("{author}", "{title}", 'false', 'true', 'false')'} This worked really well but tripped up if there were any " in the title - any way around this? not that it really matters - just curious. Many thanks for your valuable guidance - didn't even know about templates - glad I do now!! Cheers, Rob. |
04-16-2011, 02:07 AM | #4 | |
Grand Sorcerer
Posts: 11,692
Karma: 6240117
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
What you should use to get the author and title values is the field function. The complete template would be Code:
{:'strcmp(field('author'), field('title'), 'false', 'true', 'false')'} Code:
program: strcmp(field('author'), field('title'), 'false', 'true', 'false') |
|
Tags |
author:, compare fields, search, title: |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
SacBee print_version syntax | thczv | Recipes | 6 | 04-12-2011 09:38 AM |
Markdown Syntax in Comments | itimpi | Calibre | 11 | 01-25-2011 11:28 AM |
Removing header syntax. | boromirofborg | Calibre | 0 | 07-21-2010 12:33 AM |
Metadata Filename Syntax | gandor62 | Calibre | 15 | 07-18-2010 03:46 AM |
Invalid Syntax Error | msprang | Sony Reader | 7 | 11-07-2009 01:11 PM |