我使用Joomla 2.5。我正在使用MYSQL數據庫。 我有一個表job_field
有以下的列:如何編寫用於比較具有逗號分隔值的列的查詢?
cat_id | location_id
-----------------------
1,4 | 66,70
我需要將它與另一臺job_value
cat_id | location_id | name
--------------------------------
1 | 70 | Atul
4 | 70,80 | Amit
4 | 80,66 | Amol
1 | 66 | Pritam
3 | 70 | Rahul
2 | 66,90 | Ajit
1 | 74 | Raju
4 | 65,22 | Manoj
我想輸出從第一臺job_details
與第二個表比較cat_id
和location_id
列比較job_value
列cat_id
和location_id
。
它將檢查從第一表(job_details
)的每個值是location_id
列值(66,70)分別與第二表(job_value
)location_id
柱。我會得到輸出數組作爲
Array (
1 70 Atul
4 70,80 Amit
4 80,66 Amol
1 66 Pritam
)
您使用的是什麼RDBMS? –
這不是一個標準化的結構。基本上:你註定了 - 除非你重新考慮結構。 – ppeterka
以特定的sql語言方言?它是否只有一個或兩個用逗號分開的值? – rene