Solved

Show featured products

Posted on 2012-03-14
6
357 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

760 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

23 Experts available now in Live!

Get 1:1 Help Now