J
J
javanub2015-10-13 12:01:32
PHP
javanub, 2015-10-13 12:01:32

How to combine multiple SELECTs in one query?

Here are two requests, I need to combine them into one request, tell me who knows

$request = "SELECT * FROM `news` ORDER BY `news_id` DESC LIMIT 6";

            $request = "SELECT cat.*, news.*
                                FROM news_category cat, news news
                                  WHERE news.news_category_value = cat.news_category_value
                                    AND news.news_id = news.news_id";

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
IceJOKER, 2015-10-13
@IceJOKER

Do you need all the news and their categories?

SELECT news.*, cat.id, cat.title
FROM news
LEFT JOIN news_category cat ON news.category_id = cat.id
WHERE .....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question