Mysql Select Where IN Unknown column [duplicate] - mysql

This question already has answers here:
When to use single quotes, double quotes, and backticks in MySQL
(13 answers)
Closed 6 years ago.
I'm having some problem with mysql code in phpmyadmin. I want to run this code:
SELECT *
FROM table
WHERE ID
IN (
38b5f138683c57ccb1d5beec62284d8f, 08dcd7bf2fb5dc6d73d114c84c252393, bda3a36a9392a91f9142e0442e24bf24, 38963779bc562e388cbf702d6f0189cc, 98989c3c20be63f856d48a3f0584b85e
)
but I received this error: #1054 - Unknown column '38b5f138683c57ccb1d5beec62284d8f' in 'where clause'
Can anyone point me in the right direction as to the possible causes of this error?

try
SELECT * FROM table WHERE ID IN ( "38b5f138683c57ccb1d5beec62284d8f", "08dcd7bf2fb5dc6d73d114c84c252393", "bda3a36a9392a91f9142e0442e24bf24", "38963779bc562e388cbf702d6f0189cc", "98989c3c20be63f856d48a3f0584b85e" )

Related

Why are they showing syntax error for the given query? [duplicate]

This question already has an answer here:
Syntax error due to using a reserved word as a table or column name in MySQL
(1 answer)
Closed 3 years ago.
USE sql_store;
SELECT *
FROM order_items
WHERE order = 6 AND (unit_price * quantity) > 30
Look at the below image.
I tried finding what might have went wrong but I couldn't.
NOTE: I am a beginner and I started learning SQL recently.
EDIT:
order is a reserved word (as part of the order by clause). If you want to use it for a column name, you'll have to escape it by using backticks:
SELECT *
FROM order_items
WHERE `order` = 6 AND (unit_price * quantity) > 30
-- Here^-----^

unknown column in ' WHERE CLAUSE' [duplicate]

This question already has answers here:
Hyphens in column names in MySQL DB
(6 answers)
Closed 3 years ago.
I have simple sql query
it should fetch the result but showing following error:
Error Code: 1054. Unknown column 'marital' in 'where clause' 0.000 sec
The column is present in the table
SELECT * FROM usa.adult
WHERE marital-status='Never-married'
AND gender='Male'
Thanks
I believe your column name is wrong, perhaps, it is marital_status? (use an underscore instead of a hyphen.
you can use [marital-status] or 'marital-status', if the column name is infact correct.
Please check your table schema and find the correct column name.
The query should like this
SELECT * FROM usa.adult
WHERE `marital-status`='Never-married'
AND gender='Male';
You should use marital_status rather than Marital-status. Use underscore because hyphen is not allowed.

MySQLSyntaxErrorException: Unknown column 'John' in 'where clause' [duplicate]

This question already has answers here:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'Smith' in 'where clause'
(2 answers)
Closed 7 months ago.
I'm trying to retrieve records base on the keyword which is stored into skw textbox, when I pass USN or Age then it gives correct result but it's not working with Name. It throwing error:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorExceptionUnknown
column 'NAME_KEYWORD(skw)' in 'where clause'
ResultSet res=stmt.executeQuery("select * from Student where USN="+skw.getText()+" or Name='"+skw.getText()+"' or Age="+skw.getText()+"");
If you are select for text you should wrap with single quote the text values
ResultSet res=stmt.executeQuery("select * from Student where USN='"
+skw.getText()+"' or Name='"+skw.getText()+"' or Age='"+skw.getText()+"'");
otherwise the resulting text in used as column name

Unknown column in where clause. Why? [duplicate]

This question already has answers here:
Unknown Column In Where Clause
(16 answers)
Closed 8 years ago.
I use next query:
SELECT ROUND(r/h) AS conv FROM table WHERE conv > 1
I receive error "Unknown column 'conv' in 'where clause'", But why? After AS conv is it not exists yet?
The column alias isn't available until results are being produced. Try
SELECT ROUND(R / H) AS CONV
FROM TABLE1
WHERE ROUND(R / H) > 1
SQLFiddle here.
Share and enjoy.

query is wrong? [duplicate]

This question already has answers here:
#1054 - Unknown column - SQL Query Problem [duplicate]
(2 answers)
Closed 8 years ago.
SELECT *
FROM functions
WHERE isEnabled=1 AND isPrivate=0
AND user_name=high
AND function_description LIKE '%test%'
#1054 - Unknown column 'isEnabled' in 'where clause'
Try putting backticks around your isEnabled field name :
WHERE `isEnabled`=1
The isEnable field have the E Capital letter ...