What does the $ symbol do in MySQL, or how does it work? For example, I can successfully insert a value in a table field

 $UNIX_TIMESTAMP(archive_date) * 1000 

and when I try to insert the same expression without the $ character,

 UNIX_TIMESTAMP(archive_date) * 1000 

I get the error:

Unknown column 'archive_date' in 'field list'

So, does this symbol escape functions, or does it have some other value?

UPD

The fact that "I can successfully insert a value in the table field" is not a hypothetical possibility, I actually have this insertion:

enter image description here

    2 answers 2

    No, you cannot and it’s not at all clear what your first line is doing when in the second case it beats an error that there is no field.

    This character does nothing directly in MySQL and it has no purpose.

    When trying to call

     SELECT $UNIX_TIMESTAMP(archive_date) * 1000 FROM my_table 

    You will probably get an error

     FUNCTION api.$UNIX_TIMESTAMP does not exist 

    And you will get the same error if you do INSERT VALUES and if you execute $UNIX_TIMESTAMP , then most likely you have a self-written function with that name.

    The dollar symbol can be used for example in REGEXP. Backslash is used to screen variables.

    UPD:

    Judging by the last screenshot, you insert a string into the database, not a function.

     INSERT INTO table VALUES ("$UNIX_TIMESTAMP(f2312)*1000") 

    and

     ("$MARS_TIMESTAMP(go)*onemillion") 

    of course it will work, same string. But without quotes, do not insert anything.

    • The fact that "I can successfully insert a value in the table field" is not a hypothetical possibility, I actually have this insertion - Ksenia
    • @Ksenia have the ability to remove a database dump with stored procedures and functions? - cheops
    • @Ksenia And do you directly execute the code from the MySQL command line? Or is it some PHP code where $ str = "SELECT $ UNIX_TIMESTAMP ...." is inserted - Firepro
    • No, the action takes place in SQLyog - Ksenia
    • @Ksenia you insert a string into the database, not a function, according to your last update of the post and the INSERT INTO table VALUES ("$ UNIX_TIMESTAMP (f2312) * 1000") of course will work, this is the same string. And you try without quotes, nothing happens. - Firepro

    In MySQL, the $ character does not have a special meaning; perhaps you have defined a user-defined function $UNIX_TIMESTAMP() , which should distinguish it from the standard UNIX_TIMESTAMP() function or supplement it with some kind of logic.

    Often, the $ character is used to specify an alternative query delimiter in the console utility mysql

     DELIMITER $ 

    This technique is often used to create structures that contain multiple queries separated by a comma - stored procedures and functions, triggers, etc.

    • And about the second option - the use of this symbol as a separator - I know, but my case seems to have nothing to do with it ... - Ksenia
    • @Ksenia Thank you, corrected. Look for the $ UNIX_TIMESTAMP function on the dump - is there exactly such a function? - cheops
    • No, there is no such function in user functions - Ksenia
    • @Ksenia maybe some extensions installed? Is it happening locally or on the server? - cheops
    • there seems to be no extensions ... and I have remote access to the database - Ksenia