我試圖從'特定'中選擇不同的名稱,但只有col類型=特定的值。mysql從col1中選擇不同的行WHERE col2 = x
比如我有
rowID Type Specifically
1 cat Ocicat
2 cat Bombay
3 cat Bombay
4 cat Bengal
5 cat Savannah
6 dog Collie
7 dog Keeshond
8 dog Pug
9 dog Keeshond
10 dog Pug
11 dog Doberman
12 Horse n/a
我想讀出像
type=cat and specific=Bengal
type=cat and specific=Bombay
type=cat and specific=Ocicat
type=cat and specific=Savannah
我現在有這個,但它給我 '未定義指數:類型'
$Result = mysql_query("select distinct Specifically from pet_table WHERE Type='cat' ORDER BY Specifically asc ");
while($row = mysql_fetch_array($Result))
{
PRINT("type=".$row['Type']." and specific=".$row['Specifically']."<BR>");
}
我也想做類似的地方類型不是貓或狗或馬... ECT
感謝
他需要'Type'列以及 – varnie 2013-03-12 17:54:43
固定,謝謝修正 – fredrik 2013-03-12 17:56:33