Solved

Show featured products

Posted on 2012-03-14
6
361 Views
Last Modified: 2012-03-15
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
0
Comment
Question by:BrighteyesDesign
6 Comments
 
LVL 21

Assisted Solution

by:theGhost_k8
theGhost_k8 earned 250 total points
ID: 37719669
select p.* from properties p, featured f where p.propertyid=f.property_id and f.property_id in (15,16,17);

Check if this works for you! You will have to write condition after first where condition based on what you're choosing featured properties to be displyed?
0
 

Author Comment

by:BrighteyesDesign
ID: 37719967
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!
0
 
LVL 8

Expert Comment

by:santhanasamy
ID: 37720111
SELECT  p.*  FROM properties p ,featured f
WHERE p.property_id= f.property_id;
0
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 
LVL 10

Expert Comment

by:Derokorian
ID: 37720127
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
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 250 total points
ID: 37720366
I think I might let the "featured" fact be a column in the properties table.  It's not relational to anything else as far as I can see.  Then it would be SELECT things FROM table WHERE featured = 1 (or something to that effect).
0
 
LVL 21

Expert Comment

by:theGhost_k8
ID: 37723878
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!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now