W
W
Winultra2015-11-05 01:08:09
PHP
Winultra, 2015-11-05 01:08:09

How to combine two queries into one?

Hello, please help in any way you can.

$idBDInU = 1;
$querySteansNews=mysql_query("SELECT pg.*, gn.* FROM participants_groups pg, groups_news gn WHERE pg.`id_participant` = '".$idBDInU."' AND pg.`id_groups` = gn.`id_group`");
$querySteansNews=mysql_query("SELECT zt.*, f.* FROM zapisi_text zt, friends f WHERE (f.`friend1` = '".$idBDInU."' AND zt.`to` = f.`friend2`) OR (f.`friend2` = '".$idBDInU."' AND  zt.`to` = f.`friend1`)");

I need to combine two such requests into one, tell me how to do it?
I tried through join the current is displayed from zapisi_text, it is not displayed from groups_news (

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey S., 2015-11-05
@Winultra

UNION?
www.mysql.ru/docs/man/UNION.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question