
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How do I multiply an unsigned int by -1 on a MySQL SELECT?
Let us first create a table −
mysql> create table DemoTable -> ( -> Value int -> ); Query OK, 0 rows affected (0.80 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.14 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
This will produce the following output −
+-------+ | Value | +-------+ | 10 | | 20 | | 100 | +-------+ 3 rows in set (0.00 sec)
Here is the query to multiply an unsigned int by -1 on a SELECT −
mysql> select cast(Value*-1 as signed) from DemoTable;
Output
This will produce the following output −
+--------------------------+ | cast(Value*-1 as signed) | +--------------------------+ | -10 | | -20 | | -100 | +--------------------------+ 3 rows in set (0.00 sec)
- Related Articles
- What should I do? Select int as currency or convert int to currency format in MySql?
- How do I reverse an int array in Java
- How do I load an ImageView by URL on Android?
- How do I convert a char to an int in C and C++?
- Performing a MySQL LIKE comparison on an INT field?
- MySQL update a column with an int based on order?
- How do I select elements inside an iframe with Xpath?
- How do I load an ImageView by URL on Android using kotlin?
- How do I remove ON UPDATE CURRENT_TIMESTAMP from an existing column in MySQL?
- How do I select data that does not have a null record in MySQL?
- How do I SELECT none of the rows and columns in MySQL?
- How do I alter table column datatype on more than 1 column at a time in MySql?
- How do I load an image by URL on iOS device using Swift?
- How do I load an Image by URL using Picasso Library on Kotlin?
- How can I select an element by name with jQuery?

Advertisements