[SQL ] 關聯查詢的問題?

看板Database作者 (罪雲樵)時間13年前 (2011/07/27 13:36), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
[table_a] id int1 int2 (int1 幾分以下通知, int-幾分以上通知) 1 10 60 2 20 70 3 30 80 4 40 90 5 50 70 6 0 0 7 0 0 8 0 0 --------------- [table_b] id score 1 20 2 60 3 80 4 100 5 50 6 90 7 80 8 100 --------------- 我想利用table_a.int1、int2的值, 去跟table_b.score欄位進行比對…(小於int1,大於int2)的結果顯示, 而若需要達成顯示,目前是由程式進行運算,但這就會影響到頁面的筆數… 因為有比對完後,內容筆數不一定會跟sql一樣… 所以希望由sql方式進行查詢, 我目前只作到: select table_a.*, table_b.score from table_a,table_b where table_a.id=table_b.id and table_a.int1>0 and table_a.int2>0 還想不出實際比對score的動作… 請高手們指教,謝謝。 -- 習慣一個人在房間裡,安靜地享受書的內容… -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 211.75.186.7
文章代碼(AID): #1EBwF0AQ (Database)
文章代碼(AID): #1EBwF0AQ (Database)