Thread View: cn.comp.database
2 messages
2 total messages
Started by DBLobster
Thu, 22 Jun 2006 04:18
帮人问个SQL语句
Author: DBLobster
Date: Thu, 22 Jun 2006 04:18
Date: Thu, 22 Jun 2006 04:18
32 lines
1626 bytes
1626 bytes
����IJ�ѯSQL��ôд!? �����������? ��Ʒ��Product���ṹ ProductID ClassID ProductName ����Class���ṹ ClassID ClassName Class���Product����һ�Զ��ϵ ����żҪ�õ������ѯ��� ClassName ProductName Class_a1 Product_a1, Product_a2 Class_b1 Product_b1 Class_c1 Product_c1, Product_c2, Product_c3 Class_d1 ���������SELECT���Ҫ��ôд�� ���� http://www.phpx.com/happy/viewthread.php?tid=119286 0316 �ǰ���վ�� http://www.spcmusic.net/ ����лл�����
Re: 帮人问个SQL语句
Author: Lee Put
Date: Thu, 29 Jun 2006 18:14
Date: Thu, 29 Jun 2006 18:14
13 lines
2213 bytes
2213 bytes
> 现在偶要得到下面查询结果 > > > ClassName ProductName > Class_a1 Product_a1, Product_a2 > Class_b1 Product_b1 > Class_c1 Product_c1, Product_c2, Product_c3 > Class_d1 > > 请问这样的SELECT语句要怎么写? 这里面你的结果要求也算是有问题的,因为SELECT的操作对象都是关系,关系本身来讲可以俗称为一张二维表,所以你的结果要求应该是: ClassName ProductName Class_a1 Product_a1 Class_a1 Product_a2 Class_b1 Product_b1 Class_c1 Product_c1 Class_c1 Product_c2 Class_c1 Product_c3 Class_d1 NULL 那么针对这个结果来讲,我们操作就可以直接用连接就行了! 如下: SELECT ClassName, ProductName FROM Class, Product WHILE Class.ClassID=Product.ClassID; 这样子可以满足上述要求了!如果你的数据库还有进下不要求的话,那么还需要进一步把SQL查询进行加工。
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads