Page 2 of 2

Posted: Mon Jan 24, 2005 5:07 pm
by C_Calav
ah that looks like what i want!

thanx for the help!

Posted: Mon Jan 24, 2005 5:37 pm
by timvw
isn't that the same as...

Code: Select all

SELECT MAX(whateverid) FROM table

Posted: Mon Jan 24, 2005 5:41 pm
by feyd
yes. I was assuming he'll have other things in there.. eventually

Posted: Mon Jan 24, 2005 8:11 pm
by C_Calav
hi, one more question..

my q_id wont be auto_increment will it?

is there a way to add in 1, then 2, then 3 keep adding one?

Posted: Mon Jan 24, 2005 8:22 pm
by feyd
no on auto_inc

once you know the value needed, you can use an UPDATE query

Posted: Mon Jan 24, 2005 9:34 pm
by C_Calav
i dont have to use a update do i?

i want to insert a question, that will be q_no=1

then insert another question, that will be q_no=2

then stop.

the come back and insert another question, that will be q_no=3

how can i do that kind of insert?

thanx

Posted: Mon Jan 24, 2005 9:36 pm
by feyd
I have no idea why I said update... I meant insert.. I'm losing my mind today, I think.

.. not a news flash to some of you.. ;)

pretty much, you have to do a select to see what the current highest value is..

Posted: Mon Jan 24, 2005 9:59 pm
by C_Calav
cool thats what i thought, i know as much as what you just said.

im just stuck at inserting one more value at a time.

what would my insert be?

thanx feyd

Posted: Mon Jan 24, 2005 10:06 pm
by feyd
just a standard insert:

Code: Select all

INSERT INTO table (s_id, q_no, question) VALUES('3','5','How do I lop off someone''s head?')
provided your s_id is 3 and the next q_no is 5..

Posted: Tue Jan 25, 2005 12:04 am
by C_Calav
thanx feyd,

will i have to keep adding 1 all the time

for example

query=SELECT g_id FROM table WHERE s_id = $s_id ORDER BY g_id DESC LIMIT 1

query = query + 1

then insert?

Posted: Tue Jan 25, 2005 12:15 am
by feyd
that's how counter typically works.. ;)