hi i have written a query and it is giving me th following error
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 ' 2' at line 6
SELECT * FROM pretzel_product s P , pretzel_product s_description PD WHERE (P.prod_id=PD.p rod_id and prod_status<>'0 ') ORDER BY prod_date_added DESC LIMIT , 2
here is my query ,
any suggesstions -
$q="SELECT * FROM
-
".PRODUCT." P ,
-
".PRODUCT_DESCRIPTION." PD
-
WHERE
-
(P.prod_id=PD.prod_id and prod_status<>'0')
-
ORDER BY prod_date_added DESC AND LIMIT $offset , $limit ";
-
$r=execute($q);
-
3 1963 Atli 5,058
Recognized Expert Expert
Hey.
You are missing the offset in your LIMIT clause.
The manual lists it as:
[LIMIT {[offset,] row_count | row_count OFFSET offset}]
-
-- Yours is like:
-
... LIMIT , 2
-
-
-- It needs to be either
-
... LIMIT 1, 2
-
-
-- Or just
-
... LIMIT 2
-
-
-- Can also be
-
... LIMIT 2 OFFSET 1
kovik 1,044
Recognized Expert Top Contributor
So basically, the error is that your variable, $offset, is empty.
Also, there is an inconsistency between the queries being shown. In your code, you have an "AND" between the ORDER BY clause and the LIMIT clause... That is invalid syntax.
yeah that AND was a typo mistake and basically the error was that the offset variable was empty
due to which the error was occuring
hanks
regards,
Omer Aslam
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ed |
last post by:
------=_NextPart_000_001D_01C34FCC.1D2B5E50
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
There seems to be a significant penalty imposed by the optimizer when =
these
3 clauses are uses together. If we use the Full Text Search the penalty =
is
gone. However, the Full Text Search is not a very good option in my =
|
by: Randell D. |
last post by:
Folks,
I have a SELECT that returns with multiple records - It works when I have a
LIMIT clause but when I try to include a GROUP BY clause, the select returns
nothing (ie no records, no errors).
The GROUP BY specifies a column that does exist in my db (and is also the
only field that is select from the db).
Where am I going wrong? Because my select uses hashes (which I provide with
|
by: Experienced but Undocumented |
last post by:
Hi,
I have a table with three columns: datetime, subject, & author. (There are
more columns, but these are the only relavent ones.)
Some rows will have identical subjects. For each subject, I need to select
the author with the most recent date/time stamp.
Any ideas?
|
by: Experienced but Undocumented |
last post by:
Here's another one; thanks so much to everyone who helped with my last
problem. I can't upgrade mySQL but I figured out a way around it from your
examples.
SELECT `subject` , max( `datetime` )
FROM `table`
WHERE 1
GROUP BY `subject`
ORDER BY `datetime` DESC LIMIT 0 , 30
|
by: Tom Schindl |
last post by:
Hi,
the following Statement worked on MySQL 4.0 but after upgrading to
4.1.12 on win32 the order is not working any more. Is this a known
problem or is our SQL simply not useable on 4.1 or is there a bug in
MySQL 4.1.
----------------------------8<----------------------------
(
select
| |
by: Joseph R. Thomas |
last post by:
hi,
i am utilizing a web service in a C# windows application for a smart
client.
there is a method
public int ValidateUser(string userName, string password) {
object results = this.Invoke("ValidateUser", new object
{
userName,
|
by: Mark Harrison |
last post by:
I would like to try and build a queuing mechanism on top of Postgresql.
Imagine an application where a large number of processes generate images
and queue up thumbnail requests. A smaller number of processes (running
on a dedicated set of machines) generate thumbnails for those images.
Adding entries to the queue from multiple processes is easy, by executing
statements such as:
insert into nameq(action,name) values('add','foo');
|
by: dinox |
last post by:
hello, i tried searching for something similar to my situation but i haven't found so far..
for example ...
i have users table with 15 registered users and i want to show only 5 of them in front page...the table has (id) as unique value...
and i want to make an sql query that shows the 5 users registered lately...
...how?
by picking (random 5 ) users from the ( last 10 inserted users in table...) !!
this means the older ones won't...
|
by: canabatz |
last post by:
im trying to update my results and i get error:
this is the code:
this is the select :
SELECT * FROM `bidding_details` where `bid_id`='$bid_id' and `sortbid` = '1' order by bid_price asc limit 0, 50
this is the update:"
update bidding_details set sortbid = '0', rank = '0' where `bid_id`='$bid_id' and sortbid = '1' and `bid_price`='$remove_bid' LIMIT 0, 50
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |