» Quick Links
You can make money on these forums
We Share profits with you
Google
Google Adsense
Google Adwords
YPN
Yahoo
MSN Search
Web Directories
Web Hosting
Web Hosting Offers
Hosting News
Suggestions
Link Building
Domain Names
PHP Forums
MySQL Forums
» More Links
OSP News
Reseller Hosting
Shared Hosting
Dedicated Servers
Google Adsense
Search Engine Marketing
Link Development
Affiliate Marketing


» Advertising
Multiple DC PR Check

Free SEO Tools


Go Back   Webmaster Forums > Website Developement / Programming > MySQL Forums

MySQL Forums Share Your Ideas and Tips about MYSQL. Ask questions about MYSQL. Table Design and Much More...

Reply
 
Thread Tools Display Modes
  #1  
Old 11-01-2006, 05:04 AM
Endis Endis is offline
Junior Member
 
Join Date: Nov 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Endis is on a distinguished road
Default query...

hello there,
I have two tables with a one to many relationship. The advertisers table includes leads/potential advertisers so there are not adverts records for all advertisers records. I need to query the database to bring back a listing of most recent advert for an advertisers and all potential advertisers by cagegory using the following query

SELECT DISTINCT adverts.ref IS NULL AS isnull, adverts.ref, advertisers.name FROM adverts RIGHT JOIN advertisers ON adverts.busid = advertisers.id WHERE maincat=19 ORDER BY isnull ASC, MID(ref,4,2) DESC, name ASC;

The IS NULL ensures to order the records by advertisers with adverts first. Including the adverts.ref field I get the records in the right order but a record for each of the adverts an advertiser might have, however if I take this out I get all the records correctly but in an order that I cannot work out.

Any ideas would be helpful. -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Revenue Sharing Ads ( ?):
  #2  
Old 11-01-2006, 05:07 AM
ishac ishac is offline
Senior Member
 
Join Date: Jul 2006
Posts: 120
Thanks: 0
Thanked 1 Time in 1 Post
Rep Power: 18
ishac is on a distinguished road
Default

May be "adverts.ref" value may not be getting what you want. if there is a "ref" for each link to the advertisers table, you will get a distinct entry for each unique value i.e. one record for each advertiser/advert combination.
You need more refined and specific criteria to join between adverts and advertisers. -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Reply


Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mysql_affected_rows() isn't working on a delete query? zizu PHP Programming and Tips 1 08-26-2006 03:05 PM
query database kallis MySQL Forums 1 08-11-2006 03:06 PM
Query Browser issue..... Riyan MySQL Forums 1 08-04-2006 11:38 AM
upgraded 3.23 to 5.0.16 and inner join query gives an error???? Kendrick MySQL Forums 0 08-01-2006 01:18 PM
Query works on production but not on testing server parore MySQL Forums 1 07-31-2006 04:11 PM


All times are GMT. The time now is 05:52 AM.