Answer the question
In order to leave comments, you need to log in
Why does an SQL query with CONCAT work if it finds an entry for CONCAT and fail if it doesn't? How to fix?
Hello. There is such a query (written in SQL and PHP):
foreach ($words as $word) {
$tmp[] = 'CONCAT(UPPER(authors.title), " - ", UPPER(name)) LIKE UPPER("%' . $word . '%")';
}
if (!empty($tmp)) {
$query = 'SELECT items.id FROM items';
$query .= 'JOIN item_authors ON item_authors.item_id = items.id
JOIN authors ON authors.id = item_authors.author_id
WHERE ' . implode(" OR ", $tmp);
$items_ids = DB::query(Database::SELECT, $query)
->execute()
->as_array();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question