I have two tables properties and buildings. I want to extract rows from the buildings table according to a criteria.
I have put these buildings ids in a variable, as below:
$buildings = "1,2,3,4,5,6,7,8,9,10"
I am trying to access the properties according to the above list.
SELECT * FROM properties WHERE BUILDING_ID IN ('{$buildings}')
but I am not getting the desired result. How can I get the desired result? Is this the right approach?
You could do something like:
That will let you take advantage of indexes, and allow for variable IDs.
Warning: you should look into mysqli or PDO, and move away from the soon to be deprecated mysql library