Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You never refer to the <code>timestamp</code> <strong>column</strong> in your query. You only have a <strong>string</strong>:</p> <pre><code>INSERT INTO `abc` (id, 'timestamp') VALUES ('', UNIX_TIMESTAMP ( NOW () ) ) ^^^^^^^^^^^ </code></pre> <hr> <p><strong>Edit:</strong></p> <p>I get this with your updated code:</p> <blockquote> <p>ERROR 1630 (42000): FUNCTION test.NOW does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual</p> </blockquote> <p>Assuming it's not still the actual code and after fixing the syntax error, I can't reproduce your results. My educated guess is that <code>id</code> is an auto-incremented integer primary key, your current SQL mode is making MySQL take <code>''</code> as <code>NULL</code> and inserting a new row... But I haven't really tested this hypothesis.</p> <p>My working code is this:</p> <pre><code>CREATE TABLE `abc` ( `pk` INT(10) NOT NULL AUTO_INCREMENT, `id` VARCHAR(10) NULL DEFAULT NULL, `timestamp` INT(11) NOT NULL DEFAULT '0', PRIMARY KEY (`pk`) ) ENGINE=InnoDB; INSERT INTO abc (id, timestamp) VALUES ('', UNIX_TIMESTAMP()); -- Wait a few seconds INSERT INTO abc (id, timestamp) VALUES ('', UNIX_TIMESTAMP()); -- Wait a few seconds INSERT INTO abc (id, timestamp) VALUES ('', UNIX_TIMESTAMP()); SELECT timestamp FROM abc WHERE id=''; </code></pre> <p>... and returns this:</p> <pre><code>+------------+ | timestamp | +------------+ | 1342694445 | | 1342694448 | | 1342694450 | +------------+ 3 rows in set (0.00 sec) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload