How to Convert INT to String in SQLite

104 22
    • 1). Open the file containing SQLite code in an editor such as Windows Notepad.

    • 2). Open an SQLite database. In PHP this is done with the "sqlite_open" function by adding the following code:

      $db = sqlite_open('nameofdatabase', 0666, $sqlerror);

      Replace 'nameofdatabase' with your database's actual name. The '0666' argument is the default and recommended file mode. Any errors are stored in the "$sqlerror" variable.

    • 3). Send a query and use the "CAST" expression to convert an INT to a String. In PHP this is done with the "sqlite_query" function by adding the code:

      sqlite_query($db, "INSERT INTO mytable VALUES(CAST(13 AS TEXT))");

      Replace "mytable" with the name of the table you want to insert data into. In the example, the integer 13 is converted into a text data type.

    • 4). Save the file and load it on your server to execute the CAST expression.

Source...
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.