www.webdeveloper.com
Results 1 to 2 of 2

Thread: Lock Rows in INNODB

  1. #1
    Join Date
    Sep 2006
    Posts
    632

    Question Lock Rows in INNODB

    Hello


    I created a table innodb

    Code:
    CREATE TABLE `innodb` (
      `id` int(5) NOT NULL auto_increment,
      `name` varchar(9) collate latin1_general_ci NOT NULL,
      PRIMARY KEY  (`id`),
      UNIQUE KEY `name` (`name`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=21 ;

    and inserted some data into it


    Code:
    INSERT INTO `innodb` (`id`, `name`) VALUES 
    (4, 'bean'),
    (16, 'beep'),
    (8, 'bindas'),
    (14, 'done'),
    (20, 'harry'),
    (12, 'heal'),
    (7, 'indus'),
    (3, 'jim'),
    (18, 'laula'),
    (15, 'lip'),
    (13, 'none'),
    (5, 'olive'),
    (10, 'paul'),
    (17, 'paula'),
    (9, 'popla'),
    (6, 'raphel'),
    (2, 'saurab'),
    (1, 'hem'),
    (19, 'tom'),
    (11, 'zeal');

    and when I ran a query to lock the table


    Code:
    SELECT *
    FROM `innodb`
    LOCK IN SHARE MODE
    LIMIT 0 , 30


    I got the following error:


    Code:
    Error
    
    SQL query: Documentation
    
    SELECT *
    FROM `innodb`
    LOCK IN SHARE MODE
    LIMIT 0 , 30
    
    MySQL said: Documentation
    #1064 - 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 'LIMIT 0, 30' at line 2


    I was wondering what wrong in my query.

    Please assist.


    Many Thanks

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,924
    I believe the LOCK statement has to be the very last thing in the query.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles