The parenthesis stall out in the LIMIT clause, but are accepted in other areas of a query. I can do my calculations for the LIMIT start_pos, 3 in an auxiliary query.
SELECT (((2-1)*15)+3) AS start_pos;
I was hoping that I had something misplaced and could do it all in one query. Thank you...
SELECT code, name, thumbnail, image
FROM inventory
WHERE (category_id = 6)
ORDER BY name
LIMIT ((2-1)*15) , 3
I need this query statement to have the math calculation in the LIMIT clause to adjust for the page links.
((current_page_link-1)*maxrows/pg)
It keeps getting tossed out because...
The logical wording of SQL makes it easy to learn.
Consider downloading phpMyAdmin at sourceForge.net. It's a free program that helps you maintain your database and you can learn a lot about SQL statements from using it.
Far as the book goes, I haven't read it, but I've had 3 people rave about...
Thanks for responding, KarveR. Didn't work.
The site I'm working on uses the PerlShop Shopping Cart DBI module. I found the example below in the documentation. Nested query uses the "execute" command. Not sure the syntax would work for all programs, but it might.
Ashford
# Create...
Clear as the Mississippi River. Right? What I want to show on the page is:
TITLE, PRICE, DESCRIPTION,
IMAGE (if there is an image entry for this specific title),
More Details LINK (if there is a SUMMARY entry).
What I'm trying to solve is the "if":
If there is an image, show it...
I was thinking CASE would act like a subquery.
Here's an example. The company sells books. Some of the titles have images and long summaries; others, only a brief description.
What I want is a query command for
SELECT * FROM inventory
WHERE authorLast = 'Doe'
Add to the above query:
(1) show...
Is it possible to add the TableName to a query using CASE, so it could be used like an 'if...then' statement?
Ashford
SELECT FROM tableName CASE columnName
WHEN 'true' THEN 'text string-A'
WHEN 'false' THEN 'text string-B';
Vicky, first read your WebHost's FAQ to see what programs they support - SQL? mySQL? PHP? ASP?
Then do a search at http://www.about.com using a keyword string like "database mysql tutorial". Many are designed for beginners and some combine mySQL with PHP or ASP.
Once you learn the...
My 'inventory' table has a column for 'thumbnail' and another for the full size image. The data for the graphics columns is the path to the image.
product_id thumbnail
2101 /grfx/bookcover/2101.jpg
SELECT product_id, thumbnail FROM inventory
The beginning of your directory path...
I've always used the single quotes in the WHERE clause, except for when the data is numbers.
Ex: WHERE media='audio' and stock > 0;
I'll change those to see if it makes a difference.
My next quest for speed involves normalization of the inventory table, if our webhost (our mySQL server) can...
My purpose is to get the catalog pages to load faster for our bookshop.
Currently I have all the data columns for the inventory in one table. Should I split off some of the columns into their own table? Then, use the item_id# as a common factor in each table and create join queries?
Ashford...
Hi, Bob. I'm having a similar problem and not quite following what you are saying.
Our database has over 6,000 items and the 'inventory' table is indexed. The pages seem to retrieve data way too slow.
Would you please show a before and after SELECT statement to demo what you changed?
Ashford...
The site I'm working on today is a book shop for magicians. Fun stuff, huh? The inventory is slightly over 10,000.
The Feature Page showcases 4 items (listed below).
The "SELECT [col_names] FROM inventory" repeats in each query, basics like title, author, price; however, the...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.