Solved

Show featured products

Posted on 2012-03-14
6
369 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:Santhana
ID: 37720111
SELECT  p.*  FROM properties p ,featured f
WHERE p.property_id= f.property_id;
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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 109

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses how to create an extensible mechanism for linked drop downs.
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 create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

839 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