Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

запрос из 2-х таблиц

3 views
Skip to first unread message

Vladimir_Vetchinow

unread,
May 21, 2010, 3:37:24 AM5/21/10
to
Hello everybody.

����� ��������� ���� �����. php+mySQL. ������ ��� �������.
T1 (id,data,text) - �������
T2 (id,nt1,data text) - ������� �����������-������ � ����

�� ������� ���� ��� ����������, ������� �� ������ ���� ������. ������.

H���� ������� ��� ������ �1 � ���� � �2 ���� �2.nt1=�1.id
�� ������� ��� �������� �1 ��� ����������� �2

����� � �������

$result2 = mysql_query("SELECT * FROM T1 ORDER BY id DESC LIMIT ".$kol." union
select * from T2 where nt1=id, ".$nn);

H� ��� �� ���� ������... 8-(

Vladimir_Vetchinow

... *����� ��� ����� - ���������� �� ����, ��� ������ ���� �� ����.(c)B.���*

Egor Glukhov

unread,
May 22, 2010, 3:06:32 PM5/22/10
to
Good ${greeting_time}, Vladimir_Vetchinow!

21 May 10 12:37, you wrote to All:

VV> ����� ��������� ���� �����. php+mySQL. ������ ��� �������.
VV> T1 (id,data,text) - �������
VV> T2 (id,nt1,data text) - ������� �����������-������ � ����

VV> �� ������� ���� ��� ����������, ������� �� ������ ���� ������. ������.

VV> H���� ������� ��� ������ �1 � ���� � �2 ���� �2.nt1=�1.id
VV> �� ������� ��� �������� �1 ��� ����������� �2

SELECT id AS id1, NULL as id2, data, text FROM T1 UNION SELECT nt1 AS id1, id
AS id2, data, text FROM T2 ORDER BY id1,id2;

Vladimir_Vetchinow

unread,
May 24, 2010, 8:11:34 AM5/24/10
to
Hello Egor.

�c� ��� 23 2010 00:06, you wrote to me:

VV>> ����� ��������� ���� �����. php+mySQL. ������ ��� �������.
VV>> T1 (id,data,text) - �������
VV>> T2 (id,nt1,data text) - ������� �����������-������ � ����

VV>> �� ������� ���� ��� ����������, ������� �� ������ ���� ������. ������.

VV>> H���� ������� ��� ������ �1 � ���� � �2 ���� �2.nt1=�1.id
VV>> �� ������� ��� �������� �1 ��� ����������� �2

EG> SELECT id AS id1, NULL as id2, data, text FROM T1 UNION SELECT nt1 AS id1,
EG> id AS id2, data, text FROM T2 ORDER BY id1,id2;

������� �� �����. �������� ��� ����� ������.
� ������� ������� ����� ��������
printf ("H�� �������(a):<font color=#FFFF00> %s...

H� ������ �� %s �� ������������� ����������.
����� ����� �������� ��� ��������� ������?

Vladimir_Vetchinow

... *������, ������� ������ ������ ��� �� ������(c)B.���*

Vladimir_Vetchinow

unread,
May 25, 2010, 2:17:10 AM5/25/10
to
Hello everybody.

��� ��� 24 2010 17:11, I wrote to Egor Glukhov:


EG>> SELECT id AS id1, NULL as id2, data, text FROM T1 UNION SELECT nt1 AS

EG>> id1, id AS id2, data, text FROM T2 ORDER BY id1,id2;

VV> ������� �� �����. �������� ��� ����� ������.
VV> � ������� ������� ����� ��������
VV> printf ("H�� �������(a):<font color=#FFFF00> %s...

VV> H� ������ �� %s �� ������������� ����������.
VV> ����� ����� �������� ��� ��������� ������?

���������� ������� ����� ������:

$result2 = mysql_query("SELECT...

for ($data=array(); $row=mysql_fetch_assoc($result2); $data[]=$row);
echo "<pre>"; print_r($data); echo "</pre>";

������� � �����:
SELECT statements have a different number of columns
� ����� ������� ������, � ����������...
8-(


Vladimir_Vetchinow

... *� �� ���� ��������� ������ ���� �� ����!(c)B.���*

Oleg Redut

unread,
May 25, 2010, 11:14:26 AM5/25/10
to
Hello Vladimir_Vetchinow.

25 May 2010 11:17, you wrote to all:


VV>> H� ������ �� %s �� ������������� ����������.
VV>> ����� ����� �������� ��� ��������� ������?

VV> ���������� ������� ����� ������:

VV> $result2 = mysql_query("SELECT...

VV> for ($data=array(); $row=mysql_fetch_assoc($result2); $data[]=$row);
VV> echo "<pre>"; print_r($data); echo "</pre>";

while ( list[$id1, $id2, $data, $text] = mysql_fetch_row($result) ) {
echo "<pre>".$id1." - ".$id2." - ".$data." - ".$text."</pre>";
}
VV> 8-(


Oleg

... AKA oleg(&)redut.info AKA ICQ 28852595

Vladimir_Vetchinow

unread,
May 27, 2010, 11:53:56 PM5/27/10
to
Hello Oleg.

��p ��� 25 2010 20:14, you wrote to me:

VV>> ���������� ������� ����� ������:

VV>> $result2 = mysql_query("SELECT...

VV>> for ($data=array(); $row=mysql_fetch_assoc($result2); $data[]=$row);
VV>> echo "<pre>"; print_r($data); echo "</pre>";

OR> while ( list[$id1, $id2, $data, $text] = mysql_fetch_row($result) ) {
OR> echo "<pre>".$id1." - ".$id2." - ".$data." - ".$text."</pre>";
OR> }
VV>> 8-(
���� � � ����������� ���������, ���� ���, �� ��������� ��� ��.
��� �� ����� - �� ����������...

������ � �� ��� ������ �������, ������ ����(��� ����� �� �������� ����) � �����
��������� - ������ �� ������ ������� ���� ������, ������ �� ������ ������� ���,
��� �� ������ ��������. ������ �����.

���� ��� ������.
����, ���� ������ �� ������ �� ��� ���������� �������� "H�� �������"

��� ��� �� ��������:

$num_rows = mysql_num_rows($result4);
if ($num_rows<1){
echo "H�� �������";
}

��� ����������� ��������, ������ ���� >0
�������� ������� ������� ������� �����...

Vladimir_Vetchinow

... *��� �� �����, ���� ��������� ������� �����, ��� ������� �� ���(c)B.���*

Dimon

unread,
May 28, 2010, 2:44:03 AM5/28/10
to
Hi Vladimir_Vetchinow

> ��� ��� �� ��������:
>
> $num_rows = mysql_num_rows($result4);
> if ($num_rows<1){
> echo "H�� �������";
> }

if (!$num_rows)


Vladimir_Vetchinow

unread,
May 28, 2010, 7:53:28 AM5/28/10
to
Hello Dimon.

��� ��� 28 2010 10:44, you wrote to me:

>> ��� ��� �� ��������:
>>
>> $num_rows = mysql_num_rows($result4);
>> if ($num_rows<1){
>> echo "H�� �������";
>> }

D> if (!$num_rows)

�������, ��� ��������.

H�, ����� ��� ������� ���������...

Vladimir_Vetchinow

... *� ��� ������ �� ������. ������ ������� ��������. ��������.(c)B.���*

0 new messages