Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 04-15-2011, 08:46 PM   #1
rwelbourn
Junior Member
rwelbourn began at the beginning.
 
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.
rwelbourn is offline   Reply With Quote
Old 04-15-2011, 09:27 PM   #2
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by rwelbourn View Post
I need to know how to search for all books that have the same value in the author and title fields.
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.
Starson17 is offline   Reply With Quote
 
Enthusiast
Old 04-16-2011, 12:18 AM   #3
rwelbourn
Junior Member
rwelbourn began at the beginning.
 
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.
rwelbourn is offline   Reply With Quote
Old 04-16-2011, 02:07 AM   #4
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 5,195
Karma: 821512
Join Date: Jan 2010
Location: France
Device: Many android devices
Quote:
Originally Posted by rwelbourn View Post
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!!
I have no idea why that template works. It shouldn't. Sub-templates are not (supposed to be) supported. Some day I will look at it. There are probably some bugs lurking there somewhere.

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')'}
An alternate form in general program mode, slightly faster because it avoids the outermost template parsing, is
Code:
program: strcmp(field('author'), field('title'), 'false', 'true', 'false')
chaley is offline   Reply With Quote
Reply

Tags
author:, compare fields, search, title:

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

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


All times are GMT -4. The time now is 06:03 AM.


MobileRead.com is a privately owned, operated and funded community.