有沒有更簡潔的方法來編寫下面的代碼?SQL查詢難度
$myQuery = "
SELECT * FROM `rooms`
WHERE (
`Facility1` IN ($inList)
OR `Facility2` IN ($inList)
OR `Facility3` IN ($inList)
OR `Facility4` IN ($inList)
OR `Facility5` IN ($inList)
OR `Facility6` IN ($inList)
OR `Facility7` IN ($inList)
OR `Facility8` IN ($inList)
OR `Facility9` IN ($inList)
) AND `Location` LIKE '".$Location."%'
AND `RoomType` LIKE '".$RoomType."%'
ORDER BY CONVERT(`Capacity`, SIGNED)
";
你有9個'Facility'列嗎?爲什麼? – 2012-02-22 00:36:30
這是一個數據庫,我已經給與對不起 – methuselah 2012-02-22 00:40:36
明顯的答案是通過使一個設施表連接room_id設施正常化 - 是不是一個可行性? – 2012-02-22 00:43:48