Link to home
Start Free TrialLog in
Avatar of BrighteyesDesign
BrighteyesDesignFlag for Afghanistan

asked on

Show featured products

For a real estate site.....

I have a table named 'properties' which hold all of the properties details and another called 'featured' which states which properties are features.

The 'featured' table has the columns id (primary) and property_id which relates to the id on the properties table.

I basically need to know the query to display the featured properties which, at the moment would be properties with the id's 15,16 & 17 (see attachment)
Screen-shot-2012-03-14-at-10.01..png
Screen-shot-2012-03-14-at-10.01..png
SOLUTION
Avatar of theGhost_k8
theGhost_k8
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BrighteyesDesign

ASKER

Hi, thanks for that

Just one thing...15,16 & 17 are just the id's of what should show. They shouldn't be part of the query.

The query needs to be...Display properties from the 'properties' table if their ID is in the property_id column of the 'featured' table

Hope this makes sense!
SELECT  p.*  FROM properties p ,featured f
WHERE p.property_id= f.property_id;
SELECT p.* FROM featured
   LEFT JOIN  properties as p
      ON propertyID = property_id

Open in new window

Should give you what you are looking for. HTH
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That's what I meant by this I wrote earlier >>>"You will have to write condition after first where condition based on what you're choosing featured properties to be displyed?"

Btw, joins will help you out but a boolean column will ease out your task!