Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL Issue

Posted on 2014-03-03
3
Medium Priority
?
250 Views
Last Modified: 2014-03-03
What is wrong with this query?

SELECT * from subcat_docs where prim = 'Polywrap' and category = '20' Perforations' and subcategory = 'Black 200/400''

When I run this phpMyadmin, it says error in the syntax near "where catag".

The attached shows the table structure.

Thanks
subcat-docs-str.jpg
0
Comment
Question by:Richard Korts
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 18

Accepted Solution

by:
Matthew Kelly earned 1000 total points
ID: 39902009
Can you post the exact phpMyAdmin message?

I just made that table, and ran that query (copy and pasted) the below, and it ran without error.

SELECT * from subcat_docs where prim = 'Polywrap' and category = '20' Perforations' and subcategory = 'Black 200/400''

Open in new window

0
 

Author Comment

by:Richard Korts
ID: 39902105
That's crazy; I just ran it again, no error.

Can you tell we how to escape the data (from a MySQL point of view)  if there are ' in the data itself?

Thanks
0
 
LVL 35

Assisted Solution

by:Terry Woods
Terry Woods earned 1000 total points
ID: 39902108
Just add a backslash before it eg
where word = 'can\'t'

Open in new window

You can often avoid escaping by using double quotes too.

When you're writing code to perform queries with user supplied data, you need to have foolproof methods to ensure any special characters get properly escaped, or your software can become vulnerable to SQL injection attack. Let me know if you want more information on this (it's language dependent).
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this article, we’ll look at how to deploy ProxySQL.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question