Avatar of BrighteyesDesign
BrighteyesDesign
Flag 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
MySQL ServerPHP

Avatar of undefined
Last Comment
theGhost_k8

8/22/2022 - Mon
SOLUTION
theGhost_k8

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
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!
Santhana

SELECT  p.*  FROM properties p ,featured f
WHERE p.property_id= f.property_id;
Derokorian

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
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
Ray Paseur

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
theGhost_k8

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!