Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Linux, Apache, MySQL > MySQL Help

MySQL Help Post any question relating to MySQL here and hopefully someone can help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 2008-04-25, 02:07 PM
Junior Member
 
Join Date: Apr 2008
Posts: 2
sweeny500 is on a distinguished road
Default selecting info on data (meta data)

Hi I have a table as follows

Code:
CREATE TABLE `res3` (
`rec` INT NOT NULL AUTO_INCREMENT ,
`proptype` VARCHAR( 30 ) NOT NULL ,
`address` VARCHAR( 70 ) NOT NULL ,
`salelet` VARCHAR( 30 ) NOT NULL ,
`town` VARCHAR( 30 ) NOT NULL ,
PRIMARY KEY ( `rec` ) 
)
INSERT INTO `res3` ( `rec` , `proptype` , `address` , `salelet`, `town` ) 
VALUES (
'', 'House for Sale', '2 Riverside Drive', 'for sale', 'Margate'
);
INSERT INTO `res3` ( `rec` , `proptype` , `address` , `salelet`, `town` ) 
VALUES (
'', 'House for Sale', '2 Riverside Drive', 'for sale or rent','Brixton'
);
INSERT INTO `res3` ( `rec` , `proptype` , `address` , `salelet`, `town` ) 
VALUES (
'', 'House for Sale', '17 Perl Street', 'for sale', 'Margate'
);
INSERT INTO `res3` ( `rec` , `proptype` , `address` , `salelet`,  `town` ) 
VALUES (
'', 'Land for Sale', '2 Sea View Avenue', 'for sale or rent', 'London'
);
INSERT INTO `res3` ( `rec` , `proptype` , `address` , `salelet`, `town` ) 
VALUES (
'', 'Duplex for Rent', '44 Angel Crescent', 'for sale or rent', 'Oxford'
);
INSERT INTO `res3` ( `rec` , `proptype` , `address` , `salelet`, `town` ) 
VALUES (
'', 'Duplex for Sale', '17 Link Road', 'for sale', 'Oxford'
);
The data I need to retrieve is to look like this on a web page
House for Sale (4)
Oxford(3) Margate (1)

The problem is that some of the properties are 'for sale or rent'. So in the above example the stats would not be accurate because say a 'House for Rent' may also be 'for sale or rent' So I need a count of how many houses in oxford that are labelled House for Sale but also for sale or rent.
Thanks in advance
Reply With Quote
  #2 (permalink)  
Old 2008-05-06, 07:43 AM
Senior Member
 
Join Date: Dec 2004
Posts: 199
strasm is an unknown quantity at this point
Default

You have probably solved this already, but if you haven't here is the skinny. If you are just starting development on this site do yourself a favor and make two different fields for rent and sale. If you are beyond that point I will show a work around.

you can do two seperate count queries like this:

SELECT COUNT(salelet) AS salecount FROM res3 WHERE salelet LIKE '%sale%';

and

SELECT COUNT(salelet) AS rentcount FROM res3 WHERE salelet LIKE '%rent%';

Hope that helps
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.0 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.0 (a popular PHP IDE) and NuCoder 1.4 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:12 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.