What's wrong with this SQL statement? SELECT BookRec.AltAu, BookRec.Published, BookItem.Location, BookRec.Title, BookRec.Author, BookItem.CALLNBR, BookRec.Oclcno, BookItem.Avail FROM BookRec JOIN BookItem ON BookRec.OCLCNO = BookItem.OCLCNO WHERE Author or AltAu LIKE N'%smith%' ORDER BY title I'm writing a book catalog and sometimes each book has many authors, so other authors get cataloged into the AltAu field. But when people are searching by Author, I want them to also search the AltAu field. This statement works when I don't add the 'or AltAu', but I don't how how else to represent my query? Help!
SELECT BookRec.AltAu, BookRec.Published, BookItem.Location, BookRec.Title, BookRec.Author, BookItem.CALLNBR, BookRec.Oclcno, BookItem.Avail FROM BookRec JOIN BookItem ON BookRec.OCLCNO = BookItem.OCLCNO WHERE Author LIKE '%smith%' or AltAu LIKE '%smith%' ORDER BY title
Yup, SoKickIt is correct, though in my opinion I tend to stay away from using LIKE in my SQL queries. That's just me though, I've just had bad experiences with them in the past.
Not to sound all fangirly, but OMG THANK YOU! I'll experiment with the 'un-LIKE' options as well. I just used whatever was inherited from the old script
I'm glad you got it working. I just meant that using the LIKE clause can yield unexpected results sometimes, compared to an exact criteria.