SQL query on Topic name help - Posted (631 Views)
Senior Member
StephenD
Posts: 1044
1044
I've got a relatively small sized db now with 3850 topics. The topic name is unique in that I append a case no. to the end of the topic name that looks like: 4356/2006 or 4357/2006.
What I am trying to do is when posting a new topic (case) I query the db and display in post.asp the next available case no based on the highest number in the first part of that case no. + 1 so in the above example 4358/2006 will be the next suggested case no.
Then again I suppose I could create a new table with autonumber starting at last case no. linked to topic_id that I would insert a record into same time the topic gets posted, then upate forum_topics T_SUBJECT with the appended case no.
SELECT T_SUBJECT INTO FORUM_TEMPXX FROM FORUM_TOPICS WHERE RIGHT(T_SUBJECT,1)='6'
UPDATE FORUM_TEMPXX SET T_SUBJECT = RIGHT(T_SUBJECT,9)
UPDATE FORUM_TEMPXX SET T_SUBJECT = LEFT(T_SUBJECT,4)<
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
Forum Admin
HuwR
Posts: 20611
20611
Then again I suppose I could create a new table with autonumber starting at last case no. linked to topic_id that I would insert a record into same time the topic gets posted, then upate forum_topics T_SUBJECT with the appended case no.
This would be the prefered way to do it, rather than parsing the text of the subject in your query.<
 
You Must enter a message