felanor Posted June 18, 2008 Share Posted June 18, 2008 Hi Everyone, I have a very simple select statement, and I dont know why its giving me so many troubles. I am hoping someone here can provide some advice. SELECT * FROM products ORDER BY name WHERE set = 3 LIMIT 0 , 20; This here is the 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 'WHERE set = 3 LIMIT 0 , 20' at line 1 The strange part is, If I remove the "WHERE set = 3", the rest of the code runs perfectly, just as expected. Am I making a simple mistake that I am just not seeing? I've confirmed the table 'products' has a field named 'set'. I've tried encompassing both the field name and the number of that field in quotes as well as the ` sign. Thanks, ~Felanor Check Out My ScriptsFile Property Management - Adjust a file's title, author, subject, etc. Link to comment Share on other sites More sharing options...
dmob Posted June 18, 2008 Share Posted June 18, 2008 (edited) Try swapping the WHERE and ORDER BY phrases, like this: CODESELECT * FROM products WHERE set = 3 ORDER BY name LIMIT 0 , 20; Edited June 18, 2008 by dalisuit Link to comment Share on other sites More sharing options...
weaponx Posted June 18, 2008 Share Posted June 18, 2008 First, I agree with dalisuit, "ORDER BY" MUST come after "WHERE".Second, what does this have to do with AutoIt? Link to comment Share on other sites More sharing options...
dmob Posted June 18, 2008 Share Posted June 18, 2008 First, I agree with dalisuit, "ORDER BY" MUST come after "WHERE".Second, what does this have to do with AutoIt?@weaponx, it might have everything to do with AutoIt. There are AutoIt applications that access a MySQL or SQLite database.See this post for an example of such.http://www.autoitscript.com/forum/index.php?showtopic=73454 Link to comment Share on other sites More sharing options...
weaponx Posted June 18, 2008 Share Posted June 18, 2008 @weaponx, it might have everything to do with AutoIt. There are AutoIt applications that access a MySQL or SQLite database.See this post for an example of such.http://www.autoitscript.com/forum/index.php?showtopic=73454I know that. General Help & Support its for issues with AutoIt. No code was shown that uses AutoIt. Just because AutoIt can interface arbitrarily with an outside program doesn't mean we support said program. Link to comment Share on other sites More sharing options...
felanor Posted June 18, 2008 Author Share Posted June 18, 2008 Hi Guys, Thanks for all the help. It seems the version of MySQL I am running requires that the field for the WHERE clause be wrapped in the `` symbols. After putting those in and switching the ORDER BY with the WHERE, it worked perfectly. Thanks again, Felanor @weaponx, I realize that the general help and support forum is typically used for help with AutoIt script, however, I didn't know where else to turn, as I have found that those who use the forum are extremely knowledgeable and are quick to respond. The SQL statment isn't for use in an AutoIt program, rather its being used in a PHP webpage. If it was wrong of me to ask that question here, I appologize for that now. Check Out My ScriptsFile Property Management - Adjust a file's title, author, subject, etc. Link to comment Share on other sites More sharing options...
weaponx Posted June 18, 2008 Share Posted June 18, 2008 It's okay. Just for future reference, non-AutoIt topics go to Chat. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now