May 23, 2012, 04:14:01 PM
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
: Mobile users - Our forum is Tapatalk enabled.
http://www.tapatalk.com/
Home
Help
Search
Login
Register
DotDragnet
>
The Tech Side
>
Tech stuff
>
SQL Query
Pages: [
1
]
Go Down
« previous
next »
Print
Author
Topic: SQL Query (Read 617 times)
Charisma Bypass
Hero Member
Posts: 556
SQL Query
«
on:
January 13, 2010, 06:14:30 PM »
Anyone see anything wrong with this?
$top_info_query = tep_db_query("select max(products_id) as max_id FROM " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$cPath . "' and p.products_status = '1'");
Trying to get the max "product id" on a per category basis.
Error:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' categories c where p.products_id = p2c.products_id and p2c.categories_id = c.ca' at line 1
I've become fuddled. Thanks all.
Logged
JasonD
Global Moderator
Hero Member
Posts: 550
Re: SQL Query
«
Reply #1 on:
January 13, 2010, 10:10:05 PM »
You don't want a left join, replace that with a comma.
Also max(p.products_id)
Logged
Charisma Bypass
Hero Member
Posts: 556
Re: SQL Query
«
Reply #2 on:
January 13, 2010, 11:55:38 PM »
Thank you very much Jason!
Works perfectly now. TYVM
Logged
Pages: [
1
]
Go Up
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General Category
-----------------------------
=> General Discussion
=> Jee's Forum of Appalling Jokes
-----------------------------
The Creative Side
-----------------------------
=> Arty stuff
=> Photography
=> On the web
-----------------------------
The Tech Side
-----------------------------
=> Tech stuff
=> Hardware & Software
-----------------------------
The Business Side
-----------------------------
=> Anything business related
-----------------------------
The Practical Side
-----------------------------
=> Practical Advice
DotDragnet
>
The Tech Side
>
Tech stuff
>
SQL Query
Loading...