Answer the question
In order to leave comments, you need to log in
How to pull an article in mysql?
For example, you need to pull out a lesson and tags for it. I do like this:
$res = $db->query('SELECT * FROM `news` WHERE `id` = 5');
$row = $res->fetch_assoc();
//выполняю с ним какие-то операции
// И дальше делаю еще один запрос, чтобы вытащить теги
$res = $db->query('SELECT * FROM `tags` WHERE `news_id` = 5');
$row = $res->fetch_assoc();
// И тут работаю с тегами
Answer the question
In order to leave comments, you need to log in
It seems to me that all this is combined into one table or, in extreme cases, into two. What for all that that concerns one news to carry on tables?
Try JOIN.
For example like this:
SELECT * FROM `news` LEFT JOIN `tags`
ON `tags`.`news_id` = `news`.`id`
WHERE `news`.`id` = 5
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question