$g=$mysqli->query("SELECT authors.f_name, authors.s_name,books.b_name FROM authors
JOIN author_books ON authors.id=author_books.author_id JOIN
books ON books.id=author_books.book_id WHERE authors.f_name='Дмитрий' OR authors.s_name LIKE 'А%' GROUP BY authors.f_name,authors.s_name");
$g=$mysqli->query("SELECT CONCAT(authors.f_name,' ',authors.s_name) as name, books.b_name FROM authors
JOIN author_books ON authors.id=author_books.author_id JOIN
books ON books.id=author_books.book_id WHERE authors.f_name='Дмитрий' OR authors.s_name LIKE 'А%' GROUP BY name");
foreach($result as $v){
echo '<tr>
<td>'.$v['b_name'].'</td>
<td>'.$v["name"].'</td>
</tr> ';
}
SELECT a.*, b.count_book
FROM authors a,
(SELECT author_id, COUNT(book_id) as count_book
FROM author_books GROUP BY author_id
HAVING COUNT(book_id) > 1) b
WHERE a.id = b.author_id
$sql = "SELECT a.*, b.count_book FROM authors a, (SELECT author_id, COUNT(book_id) as count_book FROM author_books GROUP BY author_id HAVING COUNT(book_id) > 1) b WHERE a.id = b.author_id";
$results = $mysqli->query($sql);
foreach($results as $result) {
echo $result['f_name'] . " " . $result['s_name'] . " - " . $result['count_book'] . " книг";
}
//$_POST[POST_NAME][ROW][NAME];
$_POST[POST_NAME][0][NAME];
$_POST[POST_NAME][1][NAME];
$_POST[POST_NAME][2][NAME];
//Далее расфасовуешь
foreach($_POST[POST_NAME] as $query) {
if($model->load($query)) {
$model->save();
}
}
SELECT
IF(p.price_noch > 0,
IF(TIME(NOW()) > TIME('13:00:00'),
IF(p.price_uah > 0, IF((p.price_noch/k.kurs) < p.price_in, (p.price_in+(p.price_in*0.1))*k.kurs, p.price_noch), p.price_noch*k.kurs),
IF(TIME(NOW()) > TIME('08:00:00'), IF(p.price_uah > 0, IF((p.price_noch/k.kurs) < p.price_in, (p.price_in+(p.price_in*0.1))*k.kurs, p.price_noch) ,p.price_noch*k.kurs),'NULL')
)
, 'NULL') AS price, TIME(NOW()) AS date
FROM `product` p, (SELECT value AS kurs FROM kurs ORDER BY kurs_id DESC LIMIT 1) AS k WHERE 1