View Single Post
Old 08-04-2004, 03:26 PM   #2 (permalink)
Latch
In Your Dreams
 
Latch's Avatar
 
Location: City of Lights
I'd create two tables. One would be called "blog_entries" or whatever, and each row would contain a blog entry (title, date, contents). It would have a unique primary id as well (likely an 'int' with auto_increment on).

I'd then create another table "blog_comments", it'd have two int fields: blog_number, the blog number it's commenting on [the int autoincrement from blog_entries]; and comment_number, the number of the comment for that particular entry. Those two fields combined would create a unique primary key for every entry. The blog_comments table would also have fields like date, title, comment....

You could do a COUNT(tablename) to count the number of rows in a table.

For your last question, about getting the last number, in an auto_increment sequence when you have a newly created row (I think you mean that), check out here:

MySQL Manual | 21.2.12.3 How to Get the Unique ID for the Last Inserted Row

edit:

If you just want to find out what the latest auto_increment number is, just select MAX(auto_inc_field) from TABLE; That'll give you the highest (latest) entry number.
Latch is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43