Hi i am trying to run a query on a database, but i keep getting this error, do you see anything wrong with my query?
SELECT *
FROM `data`
WHERE `Category` LIKE '%beauty%' and not in (SELECT *
FROM `data`
WHERE `Category` LIKE 'beauty%')
thanx
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The problem is in this area:
The corect syntax is
You can’t do a subquery in a where clause where you are selecting all coumns (*) You need to select one individual column in the subquery and tie it to one column in your main query.
So the full statement should be something like
It’s equivalent to
which is a lot more readable IMO
For more info on using subqueries in an IN statement in a WHERE clause, see http://beginner-sql-tutorial.com/sql-subquery.htm
Scroll down to find “Correlated Subquery” in the article.