Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi I have a Sql statement that I appended , ran it through Control Panel phpMyAdmin, it worked but as soon as I placed it back in my php page, it throws me this error,
'Zend_Db_Statement_Mysqli_Exception' with message 'Mysqli prepare error: You have an error in your SQL syntax;


here is my sql
SQL
SELECT
               s.id,
   s.groupId,
               s.name,
               s.managerId,
               s.paymentType,
               s.mustHave,
               s.deleted
           FROM
               dealer_stores s
           INNER JOIN
               users u
           ON
               u.dealerStoreId = s.id
           WHERE userType = 'Rep'
Posted
Updated 27-Dec-11 19:44pm
v2

1 solution

Based on the SQL the only thing that quickly comes in mind is that no alias is defined for column userType. Could it be that both tables have this column so the SQL would be ambiguous. So perhaps something like:
SQL
SELECT
 s.id,
 s.groupId,
 s.name,
 s.managerId,
 s.paymentType,
 s.mustHave,
 s.deleted
FROM
   dealer_stores s
 INNER JOIN
   users u
 ON
   u.dealerStoreId = s.id
WHERE u.userType = 'Rep'

Also if you debug through the code, is that the exact statement that is used or is something appended to the SQL string.
 
Share this answer
 
Comments
[no name] 28-Dec-11 16:46pm    
Wow, good eyes ;). So 5 from a cp noob.
Wendelius 28-Dec-11 16:59pm    
Thanks, staring 20+ years to SQL develops kinda tunnel vision (in good and bad) :)
RaviRanjanKr 28-Dec-11 17:36pm    
Nice Answer Mika, My 5+
Wendelius 28-Dec-11 17:44pm    
Thanks Ravi :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900