|
The two existing table formats are as follows
pic table:
Field name type length
aid nvarchar 50
pic nvarchar 50
pic_intro nvarchar 50
products table:
Field name type length
aid nvarchar 50
a_company nvarchar 50
a_style nvarchar 50
a_type nvarchar 50
For example: the data in the products table is
aid a_company a_style a_type
11111111 aaa bb cc
22222222 aaa bb cc
33333333 aaa cc cc
44444444 aaa bb cc
55555555 aaa cc cc
The data in the pic table is
aid pic picintro
11111111 aa abcd
11111111 bb abcd
11111111 cc abcd
22222222 dd abcd
22222222 ee abcd
22222222 ff abcd
33333333 gg abcd
33333333 hh abcd
33333333 ii abcd
44444444 jj abcd
44444444 kk abcd
44444444 ll abcd
Now I want to combine the two tables to return search results that meet the conditions and display the values of the aid distinct and pic
The debug statement is: select distinct pic.aid from products, pic where products.aid = pic.aid and a_type = 'cc' and a_style = 'bb' and products.aid <> '111111'
The results that appear are:
aid
22222222
44444444
How do I display the following effect:
aid pic
22222222 dd (or ee, ff is to show only one)
44444444 jj (or kk, ll)
Please master help |
|