-3

I just typed the following query in mysql, but got this error. Is there anything wrong?

SELECT * FROM `Vs_Health_File`.`FileTask` 
WHERE `ticket` = 0ff15ff2f4b90385a75ee318e69c3248 LIMIT 1;

ERROR 1054 (42S22): Unknown column '0ff15ff2f4b90385a75ee318e69c3248' in 'where clause'

3
  • Just a tip: MySQL knows just as PHP data types. You can't put a string into a query without labeling it as a string.
    – Joshua
    Oct 30, 2013 at 8:01
  • Thanks a lot, another question, do you know how to close this question? Others are keep voting me down....@Joshua
    – Yang
    Oct 30, 2013 at 8:07
  • Below the comments there should be a close link - maybe it appears just after some time. You could also try to vote for closing it.
    – Joshua
    Oct 30, 2013 at 9:09

4 Answers 4

4

Use single-quotation marks:

SELECT * FROM Vs_Health_File.FileTask WHERE ticket = '0ff15ff2f4b90385a75ee318e69c3248' LIMIT 1;

Then the Database will interpretate it as a string. If it's MySQL you could also use backticks for table and column-names:

SELECT * FROM `Vs_Health_File`.`FileTask` WHERE `ticket` = '0ff15ff2f4b90385a75ee318e69c3248' LIMIT 1;
4
  • Back ticks are not a should. Oct 30, 2013 at 8:05
  • But what? You dont need them. - Query works without them.
    – Hecke29
    Oct 30, 2013 at 8:12
  • That's what I am saying. That its not required to use those always and hence should also use backticks is not an appropriate suggestion. Oct 30, 2013 at 8:14
  • Oh ok. I thought you wanted to say, they are a "must" ;-) I'll change it to 'could'.
    – Hecke29
    Oct 30, 2013 at 8:21
1

You should single-quote your string literals in your SQL statement:

SELECT * FROM `Vs_Health_File`.`FileTask` WHERE `ticket` = '0ff15ff2f4b90385a75ee318e69c3248' LIMIT 1;
0

Add single quotes in column value like ticket = '0ff15ff2f4b90385a75ee318e69c3248'

0

Add single Quote into your Query

`ticket` = '0ff15ff2f4b90385a75ee318e69c3248'

You can write Query like this

SELECT * FROM `Vs_Health_File`.`FileTask` WHERE `ticket` = '0ff15ff2f4b90385a75ee318e69c3248' LIMIT 1;

Also check if your database table contain ticket feald

Not the answer you're looking for? Browse other questions tagged or ask your own question.