SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
Thread: Cache results
-
Oct 10, 2001, 03:23 #1
- Join Date
- Feb 2001
- Location
- Melbourne Australia
- Posts
- 6,282
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
Cache results
Hi there,
I'm wanting to improve efficiency of my mySQL based script and what I want to be able to do is extract the top 20 rows from a table into a separate, smaller table to enable me to access this smaller table more quickly than the larger table.
I'd update it manually, as the 20 rows I need most will only change when I update the site. What is the easiest way to create a new table based on a result set?[mmj] My magic jigsaw
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Bit Depth Blog · Twitter · Contact me
Neon Javascript Framework · Jokes · Android stuff
-
Oct 10, 2001, 03:55 #2
- Join Date
- Feb 2001
- Location
- Melbourne Australia
- Posts
- 6,282
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
I've just found out how to do it:
INSERT INTO tablename SELECT ...
This causes the results from the following SELECT statement to be inserted into a table.[mmj] My magic jigsaw
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Bit Depth Blog · Twitter · Contact me
Neon Javascript Framework · Jokes · Android stuff
-
Oct 10, 2001, 03:59 #3
- Join Date
- Jul 1999
- Location
- Derbyshire, UK
- Posts
- 4,411
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It's a shame mySQL doesn't support views as they are ideal for something like this.
For anyone that doesn't know, a view in a database is just the results of a query presented like another table in the database, the database updates the view every time the tables it is made up of are changed. It's a pretty nifty feature.Karl Austin :: Profile :: KDA Web Services Ltd.
Business Web Hosting :: Managed Dedicated Hosting
Call 0800 542 9764 today and ask how we can help your business grow.
-
Oct 10, 2001, 06:46 #4
- Join Date
- Feb 2001
- Location
- Melbourne Australia
- Posts
- 6,282
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
That would be nifty.
Another way of doing what I particularly wanted in SQL databases other than mysql would be using nested select queries (which mySQL does not support, I believe).[mmj] My magic jigsaw
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Bit Depth Blog · Twitter · Contact me
Neon Javascript Framework · Jokes · Android stuff
Bookmarks