added some sql to search
This commit is contained in:
parent
cc4eadc885
commit
8c660ecaee
|
@ -272,7 +272,11 @@ def search_book(connection, search_strings, search_description=False):
|
|||
else:
|
||||
for i in range(5):
|
||||
result_list.append(s)
|
||||
c.execute('SELECT * FROM book LEFT JOIN bookperson ON book.isbn=bookperson.book LEFT JOIN person ON person.id=bookperson.person WHERE ' + ' OR '.join(where_clauses), map(lambda s:'%' + s + '%',result_list))
|
||||
c.execute('SELECT isbn,book.id AS id,title,category, \
|
||||
array_to_string(array_agg(person.lastname || \' (\' || person.id || \')\', \', \') AS persons \
|
||||
FROM book LEFT JOIN bookperson ON book.isbn=bookperson.book \
|
||||
LEFT JOIN person ON person.id=bookperson.person \
|
||||
WHERE ' + ' OR '.join(where_clauses), map(lambda s:'%' + s + '%',result_list))
|
||||
for i in xrange(c.rowcount):
|
||||
book = fetchone_dict(c)
|
||||
print book['isbn'], book['title'], book['person']
|
||||
|
|
Reference in New Issue