logo

$10
There is no reserved keyword in use, yet that is the error I get?

I run this:

mysql> explain insert into batterylog_unique (
-> select * from batterylog
-> where id in (
-> select A.id from batterylog A
-> where A.testing_date = (
-> select max(B.testing_date) from batterylog B
-> where A.brand_battery_country = B.brand_battery_country);



I get:


ERROR 1064 (42000): 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 'insert into batterylog_unique (
select * from batterylog
whe' at line 1


I look here:

http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html

The error seems to involve a reserved keyword. And yet I'm not using a reserved keyword?

UPDATE: A big thanks. I was glad to resolve this.

Lawrence Krubner | 08/01/10 at 1:11pm | Edit

Previous versions of this question: 10/30/10 at 12:51am

(4) Possible Answers Submitted...

  • avatar
    Last edited:
    08/01/10
    3:41pm
    Steven Bruni says:

    If that's your full query you're not closing your IN statement


    mysql> explain insert into batterylog_unique (

    -> select * from batterylog

    -> where id in (

    -> select A.id from batterylog A

    -> where A.testing_date = (

    -> select max(B.testing_date) from batterylog B

    -> where A.brand_battery_country = B.brand_battery_country)
    );


  • avatar
    Last edited:
    08/01/10
    1:30pm
    Daniel Zhao says:

    you parentheses do no match.
    two parentheses are missed.

  • avatar
    Last edited:
    08/01/10
    3:41pm
    William Clark says:

    Hi Lawrence,

    EXPLAIN only works with SELECT statements. Not INSERT statements.

    Take the insert wrapper off and explain your select and it will work.

    explain select * from batterylog
    where id in (
    select A.id from batterylog A
    where A.testing_date = (
    select max(B.testing_date) from batterylog B
    where A.brand_battery_country = B.brand_battery_country));

    Best regards,
    Bill

    Previous versions of this answer: 08/01/10 at 1:54pm | 08/01/10 at 1:54pm

  • avatar
    Last edited:
    08/01/10
    2:54pm
    Steven Siebert says:

    +1 William Clark. exaplain also works with a table name, which is the same as typing: describe/show columns.

    http://dev.mysql.com/doc/refman/5.0/en/explain.html

This question has expired.





Current status of this question: Completed