» 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 08-01-2006, 06:21 PM
ethan ethan is offline
OSP Starters
 
Join Date: Jul 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
ethan is on a distinguished road
Default ID difference.......

Hi,

I am running a query off of one table of articles that simply returns articleID, title, article, and image

Code:

SELECT articleID, title, article, image
FROM Articles
The articleID is an auto-increment INT field and I just need to have the query also return one more field that will indicate the difference between that particular articleID and the max articleID. So, for example, if an article has articleID 100 but the most recent articleID is 120 I need a field to return the number 20.

I know how to do this with a subquery but I am using MySQL version 4.0.1 so can’t use subqueries.

Give your suggestions -- 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 08-01-2006, 06:23 PM
winnie winnie is offline
OSP Starters
 
Join Date: Jul 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
winnie is on a distinguished road
Default

Use two queries

SELECT max(articleID) /* gives 120 */
FROM Articles

SELECT articleID, title, article, image, 120 - articleID
FROM Articles -- 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
difference... Pierce Web Hosting Industry 1 01-18-2007 08:23 AM
what's the difference? Jamya Web Hosting Industry 1 12-18-2006 03:19 AM
whats the difference?? Tlaw Reseller Hosting Forum 1 10-16-2006 04:49 AM
What's the difference between Google and Yahoo algo? Dondie Google 1 08-17-2006 10:02 AM
what 's the difference..... Jessie Web Hosting Industry 1 08-04-2006 07:35 AM


All times are GMT. The time now is 10:20 AM.