The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
MyChenQL, part 7
How can I INSERT into a table a row...but have that row be inserted into the table as the first row, not the last?
I know I can do ORDER BY but that's not a viable solution for the problem. |
#2
|
||||
|
||||
just a thought..
dont know if its possible... Somehow you could use the array_unshift function? - miSt |
#3
|
|||
|
|||
Well for PHP that would be fine but I don't believe there's an applicable MySQL function...
|
#4
|
||||
|
||||
Could you query the database to output its structure then use variables for the elements of it then use these elements in an array?
- miSt |
#5
|
|||
|
|||
I don't see how that would help
FWIW I'm trying to give ORDER BY precedence over GROUP BY, and more importantly, not have to do it with multiple queries, temporary tables, and all that extra junk. Plain-English query: select the greatest datetime from the posts table for each forumid. Posts table schema: Code:
mysql> describe posts; +--------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------+------------------+------+-----+---------+----------------+ | id | int(11) unsigned | | PRI | NULL | auto_increment | | subject | varchar(255) | | | | | | contents | text | | | | | | threadid | int(11) | | | 0 | | | forumid | int(11) | | | 0 | | | datetime | int(11) | | | 0 | | | posteruserid | int(11) | | | 0 | | +--------------+------------------+------+-----+---------+----------------+ 7 rows in set (0.00 sec) |
#6
|
|||
|
|||
SELECT forumid, MAX(datetime) AS datetime FROM posts GROUP BY forumid
something like that? |
#7
|
|||
|
|||
Don't think it's working:
Code:
mysql> select forumid,max(datetime),subject as datetime from posts group by forumid; +---------+---------------+------------------------------+ | forumid | max(datetime) | datetime | +---------+---------------+------------------------------+ | 1 | 1041622515 | first thread | | 2 | 1041623792 | first thread in second forum | +---------+---------------+------------------------------+ 2 rows in set (0.00 sec) |
#8
|
|||
|
|||
where did the subjects as datetime appear from, thats not in my query....
|
#9
|
|||
|
|||
I added it (see the query above). It seems that GROUP BY only works with the first rows it encounters.
|
#10
|
|||
|
|||
explain what you want done in proper english, you never mentioned anything about the subject.
Also use SELECT forumid, MAX(datetime) as datetime, subject FROM posts GROUP BY forumid |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|