Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

In at the deep end

Status
Not open for further replies.

llegion

Technical User
Oct 15, 2003
2
GB
I have just started with MySQL and have been thrown in at the deep end.
I have an existing site that requires a datafeed to a third party.
My problem - I am trying to extract selective data from multiple tables - which I have used the following

SELECT t_listings.f_prop_id, t_listings.f_prop_heading, t_area.f_area_name, t_listings.f_prop_postcode, t_listings.f_prop_desc, t_listings.f_prop_descmore, t_listings.f_office_id, t_propstatus.f_propstatus_desc, t_listings.f_prop_bedrooms, t_listings.f_prop_price, t_listings.f_prop_show, t_listings.f_prop_id, t_listings.f_prop_id, t_listings.f_prop_id, t_listings.f_prop_id
FROM t_listings, t_area, t_propstatus
WHERE f_prop_postcode <> '' AND f_prop_bedrooms <> '' AND f_prop_show = '1' AND f_type_id <> '135' AND t_listings.f_area_id = t_area.f_area_id AND t_propstatus.f_propstatus_desc = 'For Sale'

I now need to include a further field in my output file that includes
f_prop_heading(address), f_prop_postcode(postcode) from t_listings
and
f_area_name(town) from t_area
in the order address, postcode, town
I've been UNION without success

Any help on this would be appreciated
llegion
 
The brackets just a way of giving column names a ref for the order I need the info on following line
 
If I understand you right then this:

Code:
f_prop_heading(address), f_prop_postcode(postcode) from t_listings
and
f_area_name(town) from t_area
in the order address, postcode, town

means this:

Code:
f_prop_heading, f_prop_postcode from t_listings
and
f_area_name from t_area
in the order f_prop_heading, f_prop_postcode, f_area_name


If this is the case, you don't need a union. Since these new columns are in table already appearing in the FROM clause of your query, just edit the existing query.

Add the new column names to the SELECT clause of your query.

Add to the end of the query an ORDER BY clause which specifies your three new column names.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top